Skip to content

Async ORM mutations and queries - #134

Merged
Archmonger merged 50 commits into
reactive-python:mainfrom
Archmonger:thread-sensitive
May 6, 2023
Merged

Async ORM mutations and queries#134
Archmonger merged 50 commits into
reactive-python:mainfrom
Archmonger:thread-sensitive

Conversation

@Archmonger

@Archmonger Archmonger commented Mar 15, 2023

Copy link
Copy Markdown
Contributor

Description

fix #135

  • Disable thread_sensitive where it's not needed
  • Perform queries and mutations using async
    • use_query now supports async functions.
    • use_mutation now supports async functions.
    • django_idom.types.QueryOptions.thread_sensitive option to customize how sync queries are executed.
    • django_idom.hooks.use_mutation now accepts django_idom.types.MutationOptions option to customize how mutations are executed.
  • Use Python's arg/kwarg handlers to properly interpret and differentiate between kwarg and args. This allow things such as query=my_function to be properly handled.
  • The mutate argument on django_idom.hooks.use_mutation has been renamed to mutation.
  • Add tests for our database routing feature
  • Reduce runtime for tests from ~181 seconds to ~11 seconds by only starting the Django server once
  • Fix bug where ReactPy utilizes Django's default cache timeout, which can prematurely expire our cache entries.

Checklist:

Please update this checklist as you complete each item:

  • Tests have been included for all bug fixes or added functionality.
  • The changelog has been updated with any significant changes, if necessary.
  • GitHub Issues which may be closed by this PR have been linked.
@Archmonger

Copy link
Copy Markdown
Contributor Author

@rmorshea I'm seeing some weird behavior that might indicate a bug with async use_effect hooks.

Let me know when you have time for me to demo.

@rmorshea

Copy link
Copy Markdown
Contributor

I'll have time in an hour.

@Archmonger
Archmonger marked this pull request as draft March 16, 2023 08:09
@Archmonger
Archmonger marked this pull request as ready for review March 17, 2023 07:44
@Archmonger
Archmonger requested a review from rmorshea March 17, 2023 07:45
@Archmonger

Archmonger commented Mar 17, 2023

Copy link
Copy Markdown
Contributor Author

Ops forgot to add async mutation support...

EDIT: Past me apparently already semi-developed it, but I'm not sure what direction to take for a thread_sensitive parameter for mutations. I think we might need to create a MutationOptions data type.

@Archmonger
Archmonger marked this pull request as draft March 17, 2023 10:11
@Archmonger

Archmonger commented Mar 18, 2023

Copy link
Copy Markdown
Contributor Author

@rmorshea

Regarding a thread_sensitive parameter for mutations, which approach do we want to take?

  1. Create a MutationOptions data type with a thread_senstive parameter.
  2. Assume all sync mutations are thread_sensitive
    • If we do this, we should probably make the same assumption for our use_query hook
  3. Add a thread_sensitive=... kwarg directly to use_mutation
    • This might feel weird, since it ends up being a different API than use_query
@Archmonger
Archmonger marked this pull request as ready for review March 18, 2023 03:52
@Archmonger

Copy link
Copy Markdown
Contributor Author

This PR is ready for review.

I did a tabletop self-review and cleaned up a couple things.

@rmorshea

Copy link
Copy Markdown
Contributor

Will try to find time. Going to be quite busy the next two weeks.

@Archmonger
Archmonger requested a review from a team as a code owner March 31, 2023 02:10
@Archmonger

Copy link
Copy Markdown
Contributor Author

I played around with the test to get things running faster and more reliably.

@Archmonger

Copy link
Copy Markdown
Contributor Author

@rmorshea Can we schedule a review for this one?

@Archmonger
Archmonger merged commit d11b39a into reactive-python:main May 6, 2023
@Archmonger
Archmonger deleted the thread-sensitive branch May 6, 2023 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants