[erlang-questions] Best practices in gen_fsm usage

Andrew Thompson andrew@REDACTED
Wed Dec 7 23:31:20 CET 2011


On Wed, Dec 07, 2011 at 05:21:13PM -0500, Fred Hebert wrote:
> On Wed, Dec 7, 2011 at 12:04 PM, Max Lapshin <max.lapshin@REDACTED> wrote:
> 
> >
> > I have never ever seen any _production_ code, which is better with
> > gen_fsm. Thanks to Fred for study examples, but they are study
> > examples.
> >
> > I beleive that there may be situation, when gen_fsm is convenient. But
> > I ask only to show example of such code.
> >

Riak makes extensive use of FSMs in lots of places. A good example is the
put fsm:

https://github.com/basho/riak_kv/blob/master/src/riak_kv_put_fsm.erl

It's a FSM that models the states involved in writing a key to the
database. Of course, you *could* write this as a gen_server, but you'd
lose quite a bit of clarity.

Andrew



More information about the erlang-questions mailing list