The Story of the MongoDB Erlang Driver
Tony Hannan:
The mongodb driver has a couple of objects like connection and cursor that maintain mutable state. The only way to mutate state in Erlang is to have a process that maintains its own state that it updates when it receives messages from other processes. The Erlang programmer typically creates a process for each mutable object and defines the messages it may receive and the action to take for each message. They usually provide helper functions for the clients to call that hide the actual messages being sent and returned. Erlang OTP provides a small framework called
gen_serverto facilitate this process definition but it is still non-trivial. To alleviate this burden I created another abstraction on top ofgen_servercalled var. A var is an object (process) that holds a value of some type A that may change.
Original title and link: The Story of the MongoDB Erlang Driver (©myNoSQL)
via: http://blog.mongodb.org/post/7270427645/design-of-the-erlang-driver-for-mongodb