Company
Date Published
Author
MongoDB
Word count
903
Language
English
Hacker News points
1

Summary

The Erlang driver for MongoDB is a production-ready application that represents BSON documents as tuples with labels interleaved with values, and uses a var abstraction to manage mutable state in Erlang processes. The driver has a design decision of requiring BSON strings to be binary (UTF-8) to distinguish between strings and lists of integers. It uses gen_server or var to facilitate the process definition for mutable objects like connection and cursor, which maintain mutable state. The driver also groups a series of read/write operations into a function called a DB action, which executes within a single exception handler and with a single DB context in dynamic scope. A DB action is analogous to a DB transaction for a relational database but does not support ACID across multiple read/write operations, requiring the failure handler to recover from intermediate states.