You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I would like to be able to pass my Postgrest around my program to be able to make requests from multiple places, notably from async tasks I spawn periodically. My approach would be:
let client = postgrest.clone();let task = task_pool.spawn(asyncmove{let result = build_query(client).execute().await;handle_result(result).await});
Describe alternatives you've considered
Leave as is and require the user to either:
Create a new Postgrest at each call site. The downside to this would be that all information needed to build the client must be available as well. This breaks encapsulation as it requires users to "ship" state (access tokens, etc.) around instead of the Postgrest object, which could just do this for you.
Use Rc or similar to share the Postgrest object throughout the program. This feels redundant as Client already stores an Arc to all the persistent, non-Clone state.
Additional context
Two facts jump out at me when looking at the implementation:
Client is Clone (as are all other fields)
Constructing a Postgrest is a simple matter -- very little state is stored in the structure
Both of these hint to me that cloning should probably be a feature of the public API: if Postgrest only represents the state necessary to make a request, that state should probably be cloneable as it behaves similarly to POD.
Let me know what you think!
The text was updated successfully, but these errors were encountered:
Feature request
Hi!
Is your feature request related to a problem? Please describe.
I would like to be able to pass my
Postgrest
around my program to be able to make requests from multiple places, notably from async tasks I spawn periodically. My approach would be:Describe alternatives you've considered
Leave as is and require the user to either:
Postgrest
at each call site. The downside to this would be that all information needed to build the client must be available as well. This breaks encapsulation as it requires users to "ship" state (access tokens, etc.) around instead of thePostgrest
object, which could just do this for you.Rc
or similar to share thePostgrest
object throughout the program. This feels redundant asClient
already stores anArc
to all the persistent, non-Clone
state.Additional context
Two facts jump out at me when looking at the implementation:
Client
isClone
(as are all other fields)Postgrest
is a simple matter -- very little state is stored in the structureBoth of these hint to me that cloning should probably be a feature of the public API: if
Postgrest
only represents the state necessary to make a request, that state should probably be cloneable as it behaves similarly to POD.Let me know what you think!
The text was updated successfully, but these errors were encountered: