I recently finished a book by Joe and enjoyed it. I have since started coding a soft real-time application with erlang, and I have to say that I'm a bit confused about using gen_server.
When should gen_server be used instead of a simple stateless module? I define a stateless module as follows: - A module that takes it as a parameter (like ETS / DETS), and not internally (like gen_server)
Tell me for a module such as an invoice manager, should it initialize and return the state that I would then pass on to it? SomeState = InvoiceManager: Init (), SomeState = InvoiceManager: AddInvoice (SomeState, AnInvoiceFoo).
Suppose I need several instances of the state of an account manager (for example, my application manages several companies each with their own invoices), should they have a gene server with an internal state to manage their accounts or would it be better to correspond to the simple stateless module above ?
Where is the line between the two?
(Please note that the above account management example is an example illustrating my question)
Maitreya
source
share