mirror of https://github.com/linkerd/linkerd2.git
Closes #713. This is a follow-up from #688. This PR makes a number of refactorings to the proxy's `control::Cache` module and removes all but one of the `clone` calls. The `CacheChange` enum now contains the changed key and a reference to the changed value when applicable. This simplifies `on_change` functions, which no longer have to take both a tuple of `(K, V)` and a `CacheChange` and can now simply destructure the `CacheChange`, and since the changed value is passed as a reference, the `on_change` function can now decide whether or not it should be cloned. This means that we can remove a majority of the clones previously present here. I've also rewritten `Cache::update_union` so that it no longer clones values (twice if the cache was invalidated). There's still one `clone` call in `Cache::update_intersection`, but it seems like it will be fairly tricky to remove. However, I've moved the `V: Clone` bound to that function specifically. `Cache::clear` and `Cache::update_union` so that they no longer call `Cache::update_intersection` internally, so they don't need a `V: Clone` bound. In addition, I've added some unit tests that test that `on_change` is called with the correct `CacheChange`s when key/value pairs are modified. |
||
|---|---|---|
| .. | ||
| controller-grpc | ||
| convert | ||
| futures-mpsc-lossy | ||
| router | ||
| src | ||
| tests | ||
| Cargo.toml | ||
| Dockerfile | ||