Documentation
¶
Overview ¶
Go language actor framework.
Stability: 1 - Experimental (see: https://github.com/tristanls/stability-index#stability-1---experimental)
package main import "fmt" import "github.com/tristanls/go-actor" // create an actor behavior func Print(context actor.Context, msg actor.Message) { for _, param := range msg { fmt.Println(param.(string)) } // starting go routines within an actor behavior is *NOT SAFE* // create actors instead, that's what they're for :) } // create a new actor configuration func main() { config := actor.Configuration() config.Trace = true // trace message deliveries // create a new actor printer := config.Create(Print) // send a message to an actor printer <- actor.Message{"hello world"} // wait for actor configuration to finish config.Wait() }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActorConfiguration ¶
type ActorConfiguration struct { Trace bool // contains filtered or unexported fields }
ActorConfiguration holds the state of an actor configuration To wait for all actors to finish call ActorConfiguration.Wait(), for example:
config := actor.Configuration() // send some messages to actors config.Wait() // wait for all actors to finish
"finish" in this case means that all actors finished execution and there are no more messages in flight
func Configuration ¶
func Configuration() ActorConfiguration
Configuration creates a new actor configuration
func (*ActorConfiguration) Create ¶
func (configuration *ActorConfiguration) Create(behavior Behavior) Reference
Create creates a new actor as part of the actor configuration
func (*ActorConfiguration) Wait ¶
func (configuration *ActorConfiguration) Wait()
Wait blocks until the actor configuration finishes executing
type Become ¶
type Become func(Behavior)
Become is a function that takes the behavior to handle the next message
type Behavior ¶
Behavior describes how an actor will respond to a message. Actors are created with behaviors. Each behavior takes a context and a message to respond to. These behaviors are invoked by the library when executing an actor configuration.