go-actors: github.com/afiskon/go-actors/actor Index | Files | Directories

package actor

import "github.com/afiskon/go-actors/actor"

Index

Package Files

actor.go

type Actor Uses

type Actor interface {
    // Receive is called when Actor receives a new Message.
    // Returns a new Actor state and/or error.
    Receive(message Message) (Actor, error)
}

Actor is an entity that processes messages, sends messages to other actors and stores some state.

type Constructor Uses

type Constructor func(system System, pid Pid) (state Actor, limit int)

Constructor is a procedure that creates a new Actor. It is called when Actor is created, before receiving any Messages. `state` sets the initial actor state. If `limit` is > 0 it sets the maximum size of the mailbox (only for regular, not stashed, not priority messages).

type Message Uses

type Message interface{}

Message represents a message sent between actors.

type Pid Uses

type Pid uint64

Pid is an unique ID of the Actor.

type System Uses

type System interface {
    // Spawn creates a new Actor and returns it's Pid.
    Spawn(constructor Constructor) Pid

    // Send sends a Message to the Actor with a given Pid. InvalidPid is
    // returned if actor with a given Pid doesn't exist or was terminated.
    Send(pid Pid, message Message) error

    // SendPriority sends a priority Message to the Actor with a given Pid.
    // Priority messages are processed before any other messages. InvalidPid is
    // returned if actor with a given Pid doesn't exist or was terminated.
    SendPriority(pid Pid, message Message) error

    // AwaitTermination returns when all spawned Actors terminate.
    AwaitTermination()
}

System is a class responsible for creating, scheduling and otherwise controlling actors.

Directories

PathSynopsis
errors
mailbox
system

Package actor is imported by 2 packages. Updated 2019-06-19. Refresh now. Tools for package owners.