-
Notifications
You must be signed in to change notification settings - Fork 721
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
subscriber: make boxed subscribers not useless (#2023)
## Motivation Currently, there is an `impl<C: Collect> Subscribe for Box<dyn Subscribe<C>>` intended to allow type-erasing a subscriber. Unfortunately, however, this impl is...completely and utterly useless. In order to be set as the default, a collector must be `Send + Sync + 'static`. Because the boxed trait object does not bound the subscriber with these traits, adding a boxed subscriber to a collector will make that collector impossible to use. This means that a `Box<dyn Subscribe<C>>` has no practical purpose whatsoever. ## Solution This branch adds an `impl<C: Collect> for Box<dyn Subscribe<C> + Send + Sync + 'static>`, and removes the useless impl. In addition, I've improved the documentation on runtime configuration of subscribers to include an example of using `Box` to type-erase a subscriber. This is, incidentally, how I found out that using `Box`ed subscribers is currently useless. ## Notes * When this change is backported to v0.1.x, we'll have to un-delete the useless `impl` for `Box<dyn Layer<S>>`, as removing it is technically a breaking change. But, no one is actually _using_ that impl for any practical purpose, since they...can't. * We may want to just add a `Self: Send + Sync + 'static` bound to the `Subscribe` trait, too; this would make it much easier to avoid this kind of issue in the future. But, that's a breaking change that can't easily be backported to `v0.1.x` Signed-off-by: Eliza Weisman <eliza@buoyant.io>
- Loading branch information
Showing
1 changed file
with
136 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters