Erlang / Erlang Advanced Interview questions
What is a gen_event and when would you choose it over gen_server?
gen_event is the OTP behavior for a pub/sub-style event manager: one process holds a list of
independent handler callback modules, and any event sent to the manager is dispatched in turn to every
registered handler, each with its own private state.
{ok, Pid} = gen_event:start_link(), gen_event:add_handler(Pid, logger_handler, []), gen_event:add_handler(Pid, metrics_handler, []), gen_event:notify(Pid, {order_placed, OrderId}).
Choose gen_event when you have one stream of events that multiple, independently pluggable
consumers need to react to — logging, metrics, and alerting handlers all reacting to the same application
events, added and removed at runtime without touching the code that raises the events. A plain
gen_server is the better fit when there's a single consumer with one coherent piece of state,
rather than a fan-out to many independent listeners.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
