Code hot swapping in Erlang
Asked Answered
G

1

15

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?

Greenstein answered 3/6, 2010 at 19:1 Comment(0)
P
18

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.

Pleura answered 3/6, 2010 at 19:9 Comment(1)
@bruce14 A better option to removing a dead link is trying to find a (permanently) archived versionJaggy

© 2022 - 2024 — McMap. All rights reserved.