-
Notifications
You must be signed in to change notification settings - Fork 4
Add ability to provide custom reqwest/ureq client builder to dispatcher builder #10
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
Conversation
|
Thanks! Cherry-picked and squashed at 0a058cb |
|
@JoeJoeTV I think we are ready for v0.7? Or have you other ideas for changes/improvements? |
|
One thing that would be nice, is adding support for the serde Serialize and Deserialize traits in e.g. the Priority enum, as currently, I gave a copy of that type in my application to be able to load the configuration. |
Ref #10 (comment) Signed-off-by: Yuki Kishimoto <[email protected]>
Adj. here: 7df38ea |
Hmm, this serializes the enum to an i32, personally I was looking more into (de-)serializing it into strings, like "max", "hight", etc., so it could easily be set e.g. in a config file as a string. |
I'm de/serializing to a You can do custom de/serialization in your code. For example, wrapping the EDIT: in the curl example seems that it use the priority also as string, but I prefer the |
I am currently doing it using the derive for Serialize and Deserialize, but the easiest way to do this with an external enum which is optional in a struct and serde derive is to basically just copy the enum definition and derive the traits in addition to implementing From and Into for the actual enum. |
|
@yukibtc Maybe you could also use the I'm curious though: In which way is perfomance important for you regarding this value, since the content is sent as JSON anyways? |
Thanks, I saw this option but I didn't tried it yet. Will try it soon.
The difference isn't huge and anyway the highest (when serializing the string) is still pretty low. Probably for this library this attention to performance is not necessary, but I always prefer to use the most efficient way. Serialization of the payload as JSON, with the test payload::benches::serialize_payload ... bench: 211.86 ns/iter (+/- 101.02)Serialization of the payload as JSON, with the test payload::benches::serialize_payload ... bench: 144.87 ns/iter (+/- 35.42) |
I see the difference and I understand the want for the biggest possible performance, but I'm not sure that the serialize performance here will be the bottleneck in many situations. |
As mentioned in #9, I added functionality to provide the dispatcher builder and the Async/Blocking structs with a custom client/agent builder, so things like the user agent, which is not handled by the dispatcher builder already can be set beforehand.
I added this in the form of extra functions that take an additional argument.
If I should take a different approach, I can do that.
EDIT: This should not break anything as far as I can see, because it just adds additional functions.