Skip to content
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

[Feature Request] TimeoutLayer supports per-request values #798

Open
cglong opened this issue Oct 25, 2024 · 3 comments
Open

[Feature Request] TimeoutLayer supports per-request values #798

cglong opened this issue Oct 25, 2024 · 3 comments

Comments

@cglong
Copy link

cglong commented Oct 25, 2024

Right now, TimeoutLayer accepts a Duration parameter which specifies how long to wait before aborting a response. I'd like to customize this parameter on a per-request basis.

I'm envisioning this should be doable with a trait with one method; that method takes in a request and returns the Duration. We should be able to implement this trait for Duration itself so this won't be a breaking change.

@GlenDC
Copy link
Contributor

GlenDC commented Oct 25, 2024

I like the idea, but to be clear, this is by definition a non-breaking change. E.g. in case someone was passing a type T as .into() it will no longer compile given the compiler wouldn't know to what concrete type you want to into it.

@seanmonstar
Copy link
Collaborator

Another thought, if it's cheap for you to create or clone that portion of your service, you could inspect the request, and then clone your inner service and wrap it in a new Timeout layer and the basically oneshot.

@cglong
Copy link
Author

cglong commented Oct 25, 2024

@GlenDC, I assume that's a typo and you mean it is a breaking change. If so, thank you, that's a good callout!

@seanmonstar, yeah that should be possible for our scenario! Thank you for the workaround 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants