tower
tower copied to clipboard
Rename tower::steer?
The name steer is pretty unintuitive. Personally, it makes me think of cattle.
Perhaps we can rename it to something more concrete/descriptive in the next breaking release?
I've also thought about steer a bit. Not sure its very useful atm due to all the services having to be the same type. Unless users are cool with boxing of course.
At Embark I've made a simple Multiplex<S1, S2> middleware that routes requests between two services. Since it only accepts two services they don't have to be the same type. I'm using that to send GET /metrics to one service, GET /health/(live|ready) to another, and all other requests to a catch all 404 Not Found service. It still requires that all services are ready before sending requests but at least it doesn't require boxing.
I agree that the name isn't terribly helpful. I was looking for a "router" type Service in the listing in the Tower docs, and didn't find one, because it was named Steer. I didn't actually notice it until later when I was grepping through code.
Steering the topic slightly (ha) .... My recommendation for Steer would be to move it to documentation, and replace it with a dynamic Service that mimicks Balance's ability to use a Discover for routes. If static routes are desired, then one can use the ServiceDiscoveryList.
I have implemented such a service, (I unoriginally named it "Router") I'd be happy to submit the code, but it would probably take some tweaks from a Tower expert to make the types more friendly.
See also prior discussion here: https://github.com/tower-rs/tower/pull/426#discussion_r390623072
Do we want to address this for 0.5?