-
-
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
Query, Header Default Value Tag Feature #2699
Conversation
Signed-off-by: Murat Mirgun Ercan <[email protected]>
Signed-off-by: Murat Mirgun Ercan <[email protected]>
Thanks for opening this pull request! 🎉 Please check out our contributing guidelines. If you need help or want to chat with us, join us on Discord https://gofiber.io/discord |
Signed-off-by: Murat Mirgun Ercan <[email protected]> On branch master
Signed-off-by: Murat Mirgun Ercan <[email protected]>
Thx Can you share the benchmark results Can you put the default value handling and the tests in a separate go file (don't like big files, I'm more of a code divider)? Should we add a config setting so you can disable this handling to get the maximum performance if you don't need defaults or have your own handling? |
First, let me share the benchmark results. but These examples for ColdStart Benchmark_Ctx_QueryParser Benchmark_Ctx_QueryParserWithDefaultValues Benchmarks for multiple Request Scenario: Benchmark_Ctx_QueryParser Benchmark_Ctx_QueryParserWithDefaultValues With multiple Apart from that, we can do it for all parsers, it will be logical and we can do them with a separate file logic. In the cold start logic, there is a small cost involuntarily at first until the first cache settles, but there will be no problem after the request comes to all the handlers that contain the default structure. If we are going to integrate it into all parse structures, we can control this with the config for users who are worried about speed. If we think about the structure we're talking about, I can do that. |
Can you share the performance without and with your function for the queryparser (i.e. the times from before vs. after the adjustment) |
Sorry, I forgot it. You can check in your computer from my fork Benchmark_Ctx_QueryParser |
@muratmirgun Can you take a look at the ci failures |
move the functionality to the utils folder if you can then please add the function for all parsers and add a config setting |
Okey I am working on it! 🚀 |
Signed-off-by: Murat Mirgun Ercan <[email protected]>
Signed-off-by: Murat Mirgun Ercan <[email protected]>
Signed-off-by: Murat Mirgun Ercan <[email protected]>
just change the PR type from draft in the normal one, when you are finished with the PR |
Yes I know thanks for remember 💯 |
Signed-off-by: Murat Mirgun Ercan <[email protected]>
Signed-off-by: Murat Mirgun Ercan <[email protected]>
⚡️ improve code and provide better unittests
💚 fix ParamsParser for empty route params
Hi, I am sorry for being offline lately. I have had some health problems and I have seen your articles and now I am looking at the example given. @ReneWerner87 |
📝 update Config docs
📝 update docs
no problem, the pull request should be almost ready i have done the last steps with the other maintainers health always comes first of course, hope you are well again |
thank you very much 🙏 we will move forward again in the next issues🚀 |
utils/default.go
Outdated
} | ||
|
||
var ( | ||
mu sync.Mutex |
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.
Can this be RWMutex
?
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.
Can this be
RWMutex
?
It can. Then we should not have to be waiting for writing lock
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.
yes you are right
add more test Cases
add more test Cases
@muratmirgun maybe you can help, i found out 2 important things through the review hints
furthermore, i noticed that the performance could be optimized even further, instead of parsing and converting the value from the default tag every time, you could keep it or create a slice with closures (instead of the structElementCache), which is later only run through with the element and sets the values therefore the go-defaults also used the filler however, the biggest problem is that the functionality is not thread safe |
I saw your last commits and new test cases I am looking for your comment maybe we can make a mechanism where we can separate the default parts. I've started working on it. @ReneWerner87 . I will push new methods asap |
I am looking the last changes from this pr for sync |
another good library #2571 (comment) import "github.com/creasty/defaults" and defaults.Set(myStruct) is enough to do it outside |
that's a good question, I made a structure like this at first with the aim of less dependency because a performance problem on the library side can affect us very seriously. we must be in control. if I can't solve the thread safe problem, I will also examine the structures in this repo on the side. Because |
we exclude this feature from the current release for now by the way, it is planned to be the last v2 release |
@muratmirgun can you work on the last notes? in the v3 branch or should we rather just add documentation and recommend other packages? |
Hi @muratmirgun the PR is now closed as default feature was added in the last versions of Gorilla schema and it's been just updated for Fiber. Anyway, thanks for your contribution! |
Description
This Feature provides an approach in Go to assign default values to the fields of structs. The tagHandlers function assigns these default values based on the specific type of a field. To enhance performance, we cache which fields of the structs have default values (structCache), so we don't have to repeatedly look up these fields every time. Because Handlers Query structs not change
Fixes:
#2571
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/