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

Keeping state in the lifecycle of a request #70

Open
galdor opened this issue Jan 12, 2019 · 5 comments
Open

Keeping state in the lifecycle of a request #70

galdor opened this issue Jan 12, 2019 · 5 comments

Comments

@galdor
Copy link
Contributor

galdor commented Jan 12, 2019

I'm having issues keeping state in the lifecycle of a request. More precisely, I'd like to be able to pass data between handlers, and between init, preprocess, handle and postprocess in each handler.

It seems to be a common pattern in Erlang to explicitely propagate state, for example in gen_server, but it is not the case in elli.

#35 suggests that the only way is the process dictionary, but the Erlang website has good arguments not to overuse it (https://www.erlang.org/course/advanced#dict).

Is there anyone currently working on a patch to add an explicit state ? Would this kind of patch be accepted ?

@yurrriq
Copy link
Member

yurrriq commented Jan 13, 2019

This kind of patch is certainly welcome! And I don't know if anyone is working on anything similar currently. I had started a branch (see #44), but abadoned it. It'd be cool to use @tsloughter's ctx, but I don't think we're necessarily married to it, if you have a better, reasoned idea.

@galdor
Copy link
Contributor Author

galdor commented Jan 13, 2019

Got it. I'll try to work on a minimal version and submit a pull request for comments.

@galdor
Copy link
Contributor Author

galdor commented Jan 13, 2019

For future reference, this kind of feature would break the API. Is this ok ? It feels like it would be quite convoluted to support both the presence and absence of state everywhere.

@yurrriq
Copy link
Member

yurrriq commented Jan 14, 2019

We'll need a major version bump then.

@tsloughter
Copy link
Member

What kind of state?

Because with https://github.com/open-telemetry/opentelemetry-erlang we are going with only the process dictionary for context I think we'd do well to define standards and best practices for using the pdict this way.

The ctx library may still be of use but I want to switch it to storing stuff in the pdict instead of returning a record.

@yurrriq yurrriq mentioned this issue Feb 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants