"I'm an ACTOR framework!!!!"
Design notes for a C# actor framework
Actors
- Actors have a type and an Id
- Messages can be sent by Id
- If the Id does not exists, the message may be handled by a router
- A router can tell an appropriate supervisor to spawn the missing actor
- A router can respond with NOT_FOUND
- Messages can be sent by Type
- Many actors of the type may exist
- Routing options are:
- round robin
- attach to recipient by message type
- attach to recipient by origin type
- attach to recipient by origin Id
- Actors communicate only via messages
- Each actor has a mailbox
- The mailbox can be used to send messages to itself
- The mailbox determines parallelism, i.e. how many messages the actor can process in parallel
- The default is 1, i.e. the actor does not require locks for work since it's inherently single-threaded
Messages
- Messages are immutable
- Value payload of message
- must be serializable
- must be freezable
- Can be an expression, all members of which must obey the above
-
Directors
- All actors are spawned by a director
- Analogous to erlang style supervisors
- Directors are actors (yeah, you know they always think of themselves as actors)
- At host startup there is just the central director
- Directors can have peers
- Peers mirror each others supervision lists
- If a peer dies, the rest try to restart the peer if possible, otherwise divide its supervision list among themselves