You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is the problem your feature solves, or the need it fulfills?
The traits necessary for LoadBalancer, such as SelectionAlgorithm and BackendSelection are not object safe. This makes it not possible to use dyn Trait for implementations for this.
In river, we'd like to have runtime-selected Load Balancing, Health Checks, and Service Discovery options. This makes it difficult to determine how to properly create an instance of LoadBalancer with types chosen at runtime
Describe the solution you'd like
Ideally, if it were possible to rework these traits to be object safe, it would be possible to create something like:
I'm not certain this is a great way of doing things! It's possible I could work around the lack of object safety using my own constructions, but I wanted to bring this up in case this was an oversight, or if you had other ideas for how this could be implemented.
I'm going to dig a little deeper to see if there are changes I could propose to get the traits object safe, or if there are fundamental mismatches due to how the trait is actually used in the existing examples. Open to any pointers!
This is because pingora::Server::add_services() takes Vec<Box<dyn Service>> - essentially we are already fully erasing the type at the service level! This makes it unnecessary to do type erasure at the Service level itself (or for it's components).
Feel free to point people this way if they think that they want object safety for these traits in the future :)
What is the problem your feature solves, or the need it fulfills?
The traits necessary for
LoadBalancer
, such asSelectionAlgorithm
andBackendSelection
are not object safe. This makes it not possible to usedyn Trait
for implementations for this.In
river
, we'd like to have runtime-selected Load Balancing, Health Checks, and Service Discovery options. This makes it difficult to determine how to properly create an instance ofLoadBalancer
with types chosen at runtimeDescribe the solution you'd like
Ideally, if it were possible to rework these traits to be object safe, it would be possible to create something like:
Describe alternatives you've considered
I'm not certain this is a great way of doing things! It's possible I could work around the lack of object safety using my own constructions, but I wanted to bring this up in case this was an oversight, or if you had other ideas for how this could be implemented.
I'm going to dig a little deeper to see if there are changes I could propose to get the traits object safe, or if there are fundamental mismatches due to how the trait is actually used in the existing examples. Open to any pointers!
Additional context
This is to support the
river
project, CC memorysafety/river#39The text was updated successfully, but these errors were encountered: