actor

package
v0.0.0-...-6429144 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Actor

type Actor interface {
	Receive(msg interface{}, response *FutureTask) error
}

Actor is any object than can receive an arbitrary message.

type ActorFn

type ActorFn func(msg interface{}, response *FutureTask) error

ActorFn is a function that will be called on each message received in the inbox.

type CancelMessage

type CancelMessage struct{}

CancelMessage will cause an actor to stop when processed.

type Future

type Future interface {
	GetResult() (interface{}, error)
}

Future promises the result of a long running job.

type FutureTask

type FutureTask struct {
	// contains filtered or unexported fields
}

FutureTask is the concrete implementation of a Future.

func NewFutureTask

func NewFutureTask() *FutureTask

NewFutureTask creates a new FutureTask.

func (*FutureTask) GetResult

func (f *FutureTask) GetResult() (interface{}, error)

GetResult will provide the result of the computation. If the future is not computed yet, it will block.

func (*FutureTask) Reject

func (f *FutureTask) Reject(err error) error

func (*FutureTask) Resolve

func (f *FutureTask) Resolve(result interface{}) error

Resolve completes the computation. Any thread or goroutine waiting for GetResult() will be unblocked.

type Path

type Path struct {
	// contains filtered or unexported fields
}

Path is a unique string that identifies an actor and specifies it's ancestry.

For example: /foo/pz4h1

  	The `ancestry` is '/'. This means the actor has no ancestors -- it's a root actor.
		The `name` is 'foo'. There can be multiple actors with the same name.
		The `id` is 'pz4h1' which uniquely identifies the actor.

func (*Path) String

func (p *Path) String() string

type Ref

type Ref struct {
	// contains filtered or unexported fields
}

Ref abstracts an actor away by providing an opaque reference to it. The reference can be used to publish messages to the actor.

func (*Ref) Publish

func (r *Ref) Publish(msg interface{})

Publish will publish any arbitrary message to the actor's inbox.

func (*Ref) Request

func (r *Ref) Request(msg interface{}) Future

Request kicks off a request-response cycle. Unlike `Publish`, this function expects a response from the target actor.

type System

type System struct {
	// contains filtered or unexported fields
}

System is the root supervisor for multiple actors.

func NewSystem

func NewSystem(name string) *System

NewSystem creates a new System.

func (*System) NewActorFromFn

func (s *System) NewActorFromFn(name string, fn ActorFn) *Ref

NewActorFromFn will add, and immediately run, a new actor within the actor system.

func (*System) NewActorFromStruct

func (s *System) NewActorFromStruct(name string, actor Actor) *Ref

NewActorFromStruct will add, and immediately run, a new actor within the actor system.

func (*System) Terminate

func (s *System) Terminate() error

Terminate will cancel all actors in the system and return. This call is blocking.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL