-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
🔥 Update: add timeout context middleware #2090
Conversation
hi thanks for the work, before you go down the checklist and tick off what is already done, i would like to make one comment can we include this functionality under the current timeout middleware without causing a breaking change ? if a merge of both doesn't work, what do you think about creating another entry function? like for example timeout.NewWithContext this we can then customize later in v3 and make it controllable via configurations which are injected by changing the strategy, like with the limiter middleware what do you think ? |
Hi @ReneWerner87 , Thanks for your valuable comments. I got your point. This feature cannot be included in the current timeout middleware, current one handles timeout in a different way and has race conditions also not using context. Having a new entrypoint that you mentioned is much more clear, I've changed implementation in that way. Thanks for your suggestion. We may also think to replace the current timeout middleware with this one because it has race conditions and satisfies timeout needs. |
thx, |
since the interface is the same or just extended, I would also support the replacement unless you see any other breaking changes ? |
There is no breaking change on the signature so I replaced the current timeout middleware with the new one. |
ok thx |
great work @hakankutluay thank you! |
Please create a PR for docs repo |
PR is created on docs repo |
@hakankutluay have you tested the examples ? where does the parameter come from, don't see it in the route or routes our consumers are sometimes lazy and copy directly the examples and see how the whole thing behaves |
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.
Update docs pls
docs are also updated |
Congrats on merging your first pull request! 🎉 We here at Fiber are proud of you! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord |
Description
Timeout Context middleware for Fiber. As a fiber.Handler wrapper, it creates a context with context.WithTimeout and pass it in UserContext.
If the context passed executions (eg. DB ops, Http calls) takes longer than the given duration to return, the timeout error is set and forwarded to the centralized ErrorHandler.
It has no race conditions, ready to use on production.
Fixes #2088
Type of change
Please delete options that are not relevant.
Checklist:
Commit formatting:
Use emojis on commit messages so it provides an easy way of identifying the purpose or intention of a commit. Check out the emoji cheatsheet here: https://gitmoji.carloscuesta.me/