Hollywood is an another Actor implementation written in Rust. Whereas most Rust Actor frameworks define a system of actors within parent/child processes, Hollywood doesn't do that. Instead, an actor runs as a standalone process and all actor communication goes through NAT's.
This is extremely-alpha-only at this point. So, if you want to try it, install it as a crate dependency from github.
In your Cargo.toml:
[dependencies]
hollywood = { git = "https://github.com/grippy/hollywood", package = "hollywood" }
hollywood-macro = { git = "https://github.com/grippy/hollywood", package = "hollywood-macro" }
-
Hollywood defines an
Actortrait with the following functionality:- handle
sendtype messages that don't return a response - handle
requesttype messages where the caller expects a response - handle
subscribetype messages sent over NAT's pubsub topics
- handle
-
Hollywood defines a
Msgtrait that describes how to serialize/deserialize messages. Actor messages must implementserde::Serializeandserde::Deserialize. Hollywood defaults to usingserde::jsonbut can be overridden in the Msg trait implementation (seeinto_bytesandfrom_bytes). -
Hollywood Actors may define how to handle multiple message types. This could be useful for versioning messages. There's a macro that enables dispatching Actor messages by type.
-
Hollywood implementations may define a config file for running a "system" of actors. The main use-case is running all actors locally with one command and then watching them for changes. But this could be expanded to aid build, testing, and deployments.
Each actor should run as a standalone process. An actor has Broker which pulls messages from its mailbox. Currently, a mailbox is just a NATs subject (queue or pubsub).
Actor mailbox addresses (i.e. NATs subjects) follow this pattern:
hollywood://{system_name}@{actor_name}/{actor_version}::{msg_type}/{msg_version}
Example for MyActor which handles MyMsg v1.0:
hollywood://prod@MyActor/v1.0::MyMsg/v1.0
All actor messages are encoded as HollywoodMsg enums. From here, we define the type: Send, Request or Publish (if sending a pubsub message to a topic).
Within each type, contains the inner message consumed by an Actor. An actor should define how-to handle each HollywoodMsg variant for all inner message types and how to serialize/deserialize its own messages. By default, HollywoodMsg are passed using JSON (but this could change).
Hollywood is ~1.3K lines of code. This could change once we added a proper System test harness but for now this is a pretty small footprint.
--------------------------------------------------------------------------------
Language Files Lines Blank Comment Code
--------------------------------------------------------------------------------
Rust 12 1614 167 141 1306
--------------------------------------------------------------------------------
Here's how you run the examples. See the examples directory for code examples.
docker&docker-composeRustcargo watch
docker-compose up: this should run 3 nats containers and redis (which isn't a hollywood dependency but used as an example).
cargo build --bin=hollywood-clito compilehollywood-cli- cd
examples ../target/debug/hollywood-cli dev --system=examples --config=hollywood.toml(usescargo watchto rebuild and re-run actors on code changes) or you can manually run each actor.
The test-client shows examples of how-to call actors.
- cd
examples/test-client RUST_LOG=info cargo run