I recently saw a video about Erlang on InfoQ, In that video one of the creators presented how to replace the behavior of a message loop.
He was simply sending a message containing a lambda of the new version of the message loop code, which then was invoked instead of calling the old loop again.
Is that code hot swapping in Erlang reffers to? Or is that some other more native feature?
Yes, hot swapping in erlang servers generally refers to this feature. It is well explained in the stackoverflow question Achieving code swapping in Erlang’s gen_server, and also in this neat Erlang Generic Server tutorial or this little one.
The Erlang/OTP gen_server
module provides a generic way to achieve hot swapping, by implementing a Module:code_change/3
function in the callback module.
This way, you can upgrade a servers code without shutting it down, or fall back to former implementation if something does not work as expected. In general, hot swap should be put in place using the generic release handler.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With