How anthdm/hollywood works
Main Components
• Engine & Core Actor System – This is the heart of Hollywood and is encapsulated in the “actor” package. It is responsible for creating, managing, and supervising actors (the independent units that process messages).
• Actor Instances – Each actor is represented by components like “actor/engine.go,” “actor/pid.go,” and “actor/context.go” that exhibit the typical actor lifecycle (Initialized, Started, Stopped, etc.).
• Messaging & Event Stream – The system uses an event stream to support message routing, including handling special system events (like DeadLetterEvent or ActorRestartedEvent). This is highlighted in both the README and in components such as “actor/event.go” and “cluster/event.go.”
• Clustering & Distributed Communication – The “cluster” directory shows the support for actor clustering with files like “cluster/cluster.go” and “cluster/member_set.go.” This design provides logical separation for distributed system capabilities.
• Remote Communication – The “remote” directory demonstrates how actors communicate over the network. It involves remote configuration, TLS support, and protobuf-based message serialization (see files like “remote/remote.go” and “remote/remote.proto”).
• Supporting Utilities – Additional packages like “ringbuffer” and “safemap” are used to optimize message queues and provide thread-safe structures.
• Examples and Benchmarks – A variety of example applications (located under “examples”) illustrate scenarios such as chat applications, trade engines, and event monitoring. Benchmarks (in _bench) help validate performance claims.
Relationships and Data Flow
• Individual actors (receivers) as nodes that exchange messages via defined channels or inboxes. Emphasize that actors are uniquely identified by PIDs.
• Lifecycle message flows (e.g., from the engine to an actor for initialization, start, and stop events).
• A message routing component (via the event stream) that ensures that messages are delivered correctly and dead letters (undelivered messages) are captured.
• Demonstrate external communication between local and remote systems – show how messages can be sent over the network using dRPC and protobuf serialization. If TLS is enabled (as configured in the README for remote actors), include that in the connection details.
Architectural Patterns and Design Principles
• Actor Model – Focus on the message-passing, isolated state, and non-blocking, concurrent design of actors.
• Decentralized Communication – Emphasize local and remote message dispatch, showcasing the lightweight and fault-tolerant nature.
• Supervision/Crash Recovery – Indicate how actors are monitored and restarted upon failure, as shown by configurable options (e.g., WithMaxRestarts).
• Event-driven System – The use of event streams and logging via the built-in logger becomes a vital part of the overall design.