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

State globals in the new runtime #17

Open
josephjclark opened this issue Sep 16, 2022 · 1 comment
Open

State globals in the new runtime #17

josephjclark opened this issue Sep 16, 2022 · 1 comment
Labels
design Design issues or discussion

Comments

@josephjclark
Copy link
Collaborator

josephjclark commented Sep 16, 2022

In the v1 runtime, state is provided as a global object. So you can do stuff like this:

create({
   name: state.data.name
}});

Which is nice and good and simple.

But I'm going to suggest we remove the state global from the v2 runtime.

  • The new runtime has a stricter notion of immutable state. A cloned state object should be passed into each operation (it's an open question whether we allow mutation within the operation or if we force an immutable object).
  • This ensures the integrity of the state object in each operation, which is critical for reproducing bugs and reporting on what is happening within the job
  • But obviously with a global state object we can't do anything to preserve the integrity across operations.

This gives us a problem with legacy code which references global state. But it's easy to migrate!

@josephjclark
Copy link
Collaborator Author

Now that't v2 is live and we're migrating stuff, I'm still super keen on this.

Using a global state reference feels more like an antipattern than ever, and we should remove it from scope.

The workarounds should be super easy for migrating projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design Design issues or discussion
Projects
Status: Backlog
Development

No branches or pull requests

1 participant