Long gen_server init question (not about order of messages :)
Tue May 18 15:13:50 CEST 2021
Thank you for your response.
Option with some kind of middle-man (proxy) is one of the implementations I
was thinking about.
I'd like to clarify the option with an unregistered server.
It is very interesting, especially due to the fact that it is used in
production ( some variant of it).
But it sounds like that unregistered server starts outside of the
Or maybe without OTP at all. Is it so?
вт, 18 мая 2021 г. в 11:10, Roger Lipscombe <roger@REDACTED>:
> - The server is a singleton (within the node).
> - While the server is initializing, a caller should get 'not_ready'.
> It should not block.
> I can see two ways to do this, both involving an extra process:
> 1. The proxy starts up the server, passing self(). When the server is
> ready, it notifies the proxy. If the proxy receives a request while
> the server's not ready, it replies with 'not_ready'. If the server's
> ready, the proxy passes the request on.
> 2. The server starts in 'not_ready' mode, and starts a worker. The
> worker does the initialization, and when it's done, it sends the
> resulting state to the server. From that point, the server can reply
> to requests.
> If you want to do this without an extra process:
> - The server starts. It's initially unregistered. Any calls to the
> server look up the registration. If it's not registered, the call
> returns 'not_ready'. When it's ready, the server registers itself,
> meaning that calls can find the pid and make the call.
> We use a variant of this in production.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions