-
-
Notifications
You must be signed in to change notification settings - Fork 326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use optional_layer
builder extension
#408
Conversation
Either::B(s) | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah that is smart. Looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, they (authors of tower
) make it look so simple and elegant. I thought it'll be more complex.
I might open a feature request to include this in tower
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, that's a good idea. got two users now at least :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it merged 🎉 tower-rs/tower#555
I'll update when that's released.
fn optional_layer<T>(self, inner: Option<T>) -> ServiceBuilder<Stack<OptionalLayer<T>, L>> { | ||
self.layer(OptionalLayer { inner }) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Do we technically need to define a ServiceBuilderExt
trait for this if it's all private?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need it to add the method to ServiceBuilder
so we can use it in kube/src/service/mod.rs
.
We can't just impl<L> ServiceBuilder<L> {}
because ServiceBuilder
is not defined in this crate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, orphan rule again.
Found this in Tonic. https://github.com/hyperium/tonic/blob/cb9ed1851873343ca77f5b9254bfb1d0835d80ed/tonic/src/transport/service/layer.rs