-
Notifications
You must be signed in to change notification settings - Fork 17
Add register flag for Store instantiation #547
Copy link
Copy link
Closed
Labels
enhancementNew features or improvements to existing functionalityNew features or improvements to existing functionality
Description
Describe the Request
The docs frequently suggest the following pattern:
store = Store('my-store', ...)
register_store(store)We can change this to an easier one-liner by adding a register flag to Store.
store = Store('my-store', ..., register=True)In this case, Store can become a singleton type, returning an existing instance if one with a matching name exists and otherwise instantiating a new one and registering it. By default, register=False preserving all prior functionality and skipping the singleton factory.
This opt-in singleton pattern would help prevent users from instantiating the same Store by accident multiple times in the same process, negating the cache/connector persistence benefits.
This might also require some other changes/considerations:
- Add a
get_or_create_store()function and move the store lock out of the factory so it can be used in bothget_store()andget_or_create_store()(freestanding, in the factory, or in the store singleton factory).
https://github.com/proxystore/proxystore/blob/ac3800dbb67b6624b303ca75fa7e1ce99e81dcfe/proxystore/store/factory.py#L104C1-L109C25 registeris included in the store's config.- Update docs to suggest
registerrather thanregister_store().
Sample Code
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew features or improvements to existing functionalityNew features or improvements to existing functionality