Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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 is persistent ? #1

Closed
jbjuin opened this issue Nov 30, 2021 · 1 comment
Closed

State is persistent ? #1

jbjuin opened this issue Nov 30, 2021 · 1 comment

Comments

@jbjuin
Copy link

jbjuin commented Nov 30, 2021

Hi, nice project, it's cool to see an experiment like this.
I didn't look at the code but is the state restored if the actor (task) is restarted ?
Although I never used the real OTP (nor do I know erlang), from what I read about it it should be, am i right ?
Anyway, thanks for sharing this, it's quite inspiring !

@linkdd
Copy link
Owner

linkdd commented Nov 30, 2021

Hello @jbjuin

Thanks for the feedback 😄

I think you're talking about the state of a gen_server. In that case, no the state is not restored (same for the real OTP).

The state of a gen_server is temporary and lives only in memory. It's very common to have a connection handle to a database as state for example. If a temporary network failure occurs, the gen_server will crash and be restarted by the parent supervisor, creating a new connection (successfully once the temporary network failure is resolved).

If you need persistance, the real OTP gives you:

  • ETS (Erlang Term Storage), an in-memory key/value store that runs in its own process (or task)
  • DETS (Distributed ETS), which is replicated/balanced over the cluster. We can't do that here, this library does not support clustering (yet???)
  • Mnesia, which is based on DETS and allows on-disk persistance (if you know RabbitMQ, that's what they use to store the messages)

Yes, in the Erlang/Elixir world you don't need Redis 😉

TL;DR: If you need persistance over restarts, you should rely on an external service like Redis, Memcached, or a database, and hold the connection to this service in the gen_server's state

Repository owner locked and limited conversation to collaborators Dec 1, 2021
@linkdd linkdd closed this as completed Dec 1, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants