Skip to content
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

.getAll() the entire state at once #430

Open
PfisterFactor opened this issue Sep 5, 2024 · 2 comments
Open

.getAll() the entire state at once #430

PfisterFactor opened this issue Sep 5, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@PfisterFactor
Copy link

Currently if I want to get the entire key value state on a virtual object - I need to .get each key individually.

It would be nice if a .getAll() function existed that returned the entire state in one atomic call.

@PfisterFactor PfisterFactor changed the title Fetch the entire state at once .getAll() the entire state at once Sep 5, 2024
@slinkydeveloper slinkydeveloper added the enhancement New feature or request label Sep 6, 2024
@slinkydeveloper
Copy link
Contributor

Hi @PfisterFactor thanks for reporting this issue. Just for my understanding, why it's important to have one atomic call for getting all the state? Are you trying to access the state values from a shared virtual object handler, or from a regular virtual object handler? Because if you're trying to access state from a regular virtual object handler, you cannot have two concurrent handlers trying to read/write state keys at the same time, so a loop like:

for key in ctx.stateKeys():
  ctx.get(key)

Should be enough.

Also did you consider storing all your virtual object state as an individual key in the K/V store?

@PfisterFactor
Copy link
Author

PfisterFactor commented Sep 17, 2024

Atomic in the sense of just one round-trip to the state is necessary. Not in the multithreaded sense as like you said the exclusivity guarantees make this safe.

I suppose more just for convenience and ease of use, as it gets annoying to have to write a loop all the time instead of just .getAll.

Nesting the state in one top level field works but is just inconvenient

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants