-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
[Dart2] Add initial support to use an isolate to offload JSON serialization/deserialization #9100
[Dart2] Add initial support to use an isolate to offload JSON serialization/deserialization #9100
Conversation
…n serializing/deserializing.
While technically this is backwards incompatible change, it doesn't feel like it. Good practice should be accepted. |
That's great to hear! Thanks for the approval. I'll get the pr to pass all tests asap. |
It's still up to @wing328 to decide whether this gets in 5.2 or 6.0, but for me it's a candidate for 5.2. Breaking change is minimal, but benefits are big. |
ps: after implementing the offloading via |
Nice, what do you think about creating a service with isolates for api client? apiClient would be wrapped in an isolate rather than |
I think this is beyond the scope of what the API client should be. One can always use it inside an isolate, but from my experience it's not needed at all. The heaviest operations in the client are JSON serialization/deserialization, and I think this pr would solve that bottleneck with minimal changes. |
Can you add a comment that the synchronous method is deprecated and marked for removal in 6.0? |
There is a deprecation already, but I'll add the note about removal in 6.0. |
@agilob @wing328 @kuhnroyal |
You previous changes to the tests should have solved this and the test succeeds for me. The issue is causes by adding multiple pets to the Although we can probably remove one of the tests (openapi-2). |
modules/openapi-generator/src/main/resources/dart2/api_client.mustache
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/dart2/api_client.mustache
Outdated
Show resolved
Hide resolved
This should be done separately, for now you should just fix both tests in the same way you did earlier. |
I rolled back my "fix", but can certainly bring it back. Do you think it'll solve the tests? |
Yes I do and it did :) |
woo hoo! that was an awesome input, thank @kuhnroyal. |
What's left for merging? :) |
@noordawod just merged. Thanks for the PR. @agilob @kuhnroyal thanks for the review. |
@noordawod any chance to add support for null-safety and dart >= 2.12 ? Thanks! |
I have noticed that as my API grew and its associated data requirements grew with it, a Flutter app I work on started showing hickups (jank) when a lengthy JSON hit the wire. So, I wanted to offload to a
compute()
function but was unable due to the fact thatApiClient._deserialize
is private. Hence this pr.In addition, I had to adjust the signatures of some functions and methods to be futures and that means that this pr is not backward-compatible. So if users have overridden
serialize()
ordeserialize()
then they'll need to update their code to match the new signature. A matter of 5 minutes but the change allows a better concurrency regardless if one uses an isolate or not.PR checklist
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.For Windows users, please run the script in Git BASH.
master
,5.1.x
,6.0.x
@ircecho (2017/07) @swipesight (2018/09) @jaumard (2018/09) @athornz (2019/12) @amondnet (2019/12) @wing328 @sbu-WBT @agilob