How kandoo/beehive works
Project type and purpose
• Beehive is a Go-based distributed programming framework.
• It provides primitives for asynchronous message passing, sharding/partitioning (Map), replicated state (dictionaries), fault-tolerance (Raft), transactions, HTTP and detached handlers, and live instrumentation.
File structure
• Top-level Go entrypoints:
• app.go, hive.go, web.go – core server and HTTP API
• registry.go, replication.go, rpc.go – cluster membership, replication logic, RPC interface
• raft/ – in-process Raft implementation for consensus and replication
• compiler/ – codegen of Map functions
• composition/, bucket/, state/ – utility packages for message composition, in-memory state, transaction support
• examples/ – sample apps illustrating HelloWorld, KV store, task queue, routing, detached handlers
• Godeps/ – vendored dependencies (gorilla/mux, protobuf, etc.)
• Tests scattered alongside each package confirm functionality.
Extract architectural insights from the README
• Hives = cluster nodes hosting Bees (worker goroutines).
• Applications = sets of message handlers. Each handler has a Map (for sharding) and Rcv (business logic).
• Bees own “cells” (dictionary keys) and execute Rcv under a transaction.
• Cell ownership and replication use Raft: each cell is replicated to a colony of Bees (size = replication factor).
• Messages flow: Emit → Map → route to owning Bee (local or remote) → Rcv → state updates & new messages.
• Extensions: HTTP handlers mounted at /apps/APP_NAME/, Detached handlers for external I/O, instrumentation for live optimization.
Detail
• Break the core engine into: Dispatcher, Transaction Manager, Bee Pool, Dictionary Store, Raft subsystem
• How multiple applications register handlers with the Dispatcher
• Clustered Hives and peer discovery via the registry module
• Call out configuration and command-line flags that control ports, replication factor, instrumentation