$ show vladopajic/go-actor
go-actor is a Go library implementing the Actor model for concurrent programming. It provides core abstractions: Actor (with Start/Stop), Worker (defining work via DoWork), and Mailbox for message passing. The library enables building concurrent systems without mutexes by leveraging goroutines and channels. Key features include non-blocking message sends (by default), combinable actors for collective lifecycle management, and pluggable mailbox modes (internal queue or Go channel wrapper). The design emphasizes zero-overhead composition, graceful shutdown, and compatibility with Go's scheduler. The codebase is well-tested, actively maintained, and follows modern Go practices with rigorous CI/linting.
The LLM identified 2 files worth highlighting for reuse:
Implements a mailbox with two modes: internal queue (non-blocking send) and Go channel wrapper. Handles lifecycle correctly (send returns error after stop, receive channel closes on stop). Demonstrates non-obvious skill in balancing performance, safety, and usabilityβe.g., tracking ongoing sends to avoid closing receive channel prematurely during concurrent stops. Self-contained; depends only on queue package and stdlib sync/atomic. Extractable for any concurrent system needing reliable message passing.
Combines multiple Actor (or any Start/Stop) objects into one that manages their collective lifecycle. Supports options for stopping together, in parallel, or with custom start/finish hooks. Shows expertise in handling concurrency pitfalls (e.g., avoiding double-stop via atomic flags, preventing recursive stops via goroutine isolation). Minimal dependencies (sync/atomic). Reusable for managing lifecycle of any set of start/stop components (e.g., servers, resources) beyond actors.