-
-
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
🚀 [Feature]: Allow rebuilding route tree stack #2769
Comments
Thanks for opening your first issue here! 🎉 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord |
we can allow this as a feature in version 3 |
I can check this out! I'll be making sure that the method can be thread-safe and make a PR |
You can check https://github.com/gofiber/fiber/tree/export-buildtree branch. I've implemented the necessary mutexes to make the feature threas-safe but it affected the results of parallel Next benchmarks. without mutex: with mutex: with rwmutex: |
@efectn To avoid the Mutex we would need a separate Tree that's a copy of the main one. We can then sync changes to that one if the User generates dynamic routes?
|
Wouldn't it complicate the Next since we are going to have 2 route tree? |
It would probably still need mutexes to sync the changes no? Because if you're trying to rebuild it in runtime you would run the risk of reading or writing twice into the actual route tree. Like if you call the BuildTree method in two handlers that receive a request at the same time. If the increase in the benchmarks are really unnaceptable, I don't know if this should go ahead, it will for sure increase the execution time inevitably. I'm a recent contributor, so I may be wrong about this, but from what I know this would happen eventually. |
@luk3skyw4lker Yeah, I was reading the ticket wrong 😂 We had a discussion about it on Discord. Adding this def makes Fiber slower. I think the idea may be to add it without the mutex but a big warning to the user, right? @efectn Only a mutex in the public |
@gaby happens to the best of us 😆 I should probably pay more attention at the Discord too tho, would love to be part of this discussion. I wouldn't be a big fan of adding it without the mutexes but as I said, if the benchmark increases are in fact really unnaceptable, it would definitely be the best way to go. |
Feel free to create a PR. I've been also planning to return params on |
Feature Description
I was thinking it'd be awesome if the
buildTree
method inApp
could be made public. This tweak would open up possibilities for dynamic request handling.already checked #735 I get that rebuilding the tree might be resource-intensive, but we'd only use it during development. This way, we can ensure our routing behaves as expected without resorting to an
*
route and redoing all the routing and parsing logic.Our goal is to enable users to define routes dynamically, with handlers loaded in on-the-fly. So, by simply making the buildTree method public, it'd really help us out.
Additional Context (optional)
The code snippet below illustrates how making
buildTree
public could streamline fiber routing without the need for using *.Code Snippet (optional)
No response
Checklist:
The text was updated successfully, but these errors were encountered: