core

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: Apache-2.0 Imports: 4 Imported by: 3

Documentation

Index

Constants

View Source
const (
	ACTOR_RESTART = iota
	ACTOR_RETRY
	ACTOR_FAIL
)
View Source
const (
	SUPERVISOR_RESTART = iota
	SUPERVISOR_FAIL
	SUPERVISOR_IGNORE
)
View Source
const DefaultRegistrySize = 100

Variables

This section is empty.

Functions

This section is empty.

Types

type Actor

type Actor interface {
	Start()
	Stop()
	SendMessage(msg interface{})
	GetID() uuid.UUID
	GetName() string
	GetContext() context.Context
	SetWaitGroup(wg *sync.WaitGroup)
	SetContext(ctx context.Context)
	SetFailureChannel(chan *ActorResult)
}

type ActorMonitor

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

ActorMonitor manages communication between actors and their supervisor

func NewActorMonitor

func NewActorMonitor(s *Supervisor) *ActorMonitor

NewActorMonitor creates a new monitor for actors

func (*ActorMonitor) GetInboundChannel

func (m *ActorMonitor) GetInboundChannel() chan *ActorResult

type ActorRegistry

type ActorRegistry struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewActorRegistry

func NewActorRegistry(size ...int) *ActorRegistry

func (*ActorRegistry) GetActor

func (ar *ActorRegistry) GetActor(id string) (Actor, bool)

func (*ActorRegistry) RegisterActor

func (ar *ActorRegistry) RegisterActor(actor Actor)

type ActorResult

type ActorResult struct {
	Error   error
	Action  int
	Message interface{}

	ID uuid.UUID
	// contains filtered or unexported fields
}

type BasicActor

type BasicActor struct {
	ReceiveFunc func(result *ActorResult) *ActorResult
	// contains filtered or unexported fields
}

func NewBasicActor

func NewBasicActor(name string) *BasicActor

recieveFunc func(result *ActorResult) *ActorResult

func NewBasicActorWithMailboxSize

func NewBasicActorWithMailboxSize(name string, size int) *BasicActor

func (*BasicActor) GetContext added in v0.0.4

func (a *BasicActor) GetContext() context.Context

func (*BasicActor) GetID

func (a *BasicActor) GetID() uuid.UUID

func (*BasicActor) GetName

func (a *BasicActor) GetName() string

func (*BasicActor) SendMessage

func (a *BasicActor) SendMessage(msg interface{})

func (*BasicActor) SetContext

func (a *BasicActor) SetContext(ctx context.Context)

func (*BasicActor) SetFailureChannel

func (a *BasicActor) SetFailureChannel(failure chan *ActorResult)

func (*BasicActor) SetWaitGroup

func (a *BasicActor) SetWaitGroup(wg *sync.WaitGroup)

func (*BasicActor) Start

func (a *BasicActor) Start()

func (*BasicActor) Stop

func (a *BasicActor) Stop()

type InMemoryBroker

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

InMemoryBroker is an in-memory implementation of the MessageBroker interface

func NewInMemoryBroker

func NewInMemoryBroker() *InMemoryBroker

NewInMemoryBroker creates a new in-memory broker

func (*InMemoryBroker) Publish

func (b *InMemoryBroker) Publish(topic string, msg interface{}) error

Publish sends a message to all actors subscribed to the topic

func (*InMemoryBroker) Subscribe

func (b *InMemoryBroker) Subscribe(topic string, actor Actor) error

Subscribe adds an actor to the list of subscribers for a given topic

type MessageBroker

type MessageBroker interface {
	Publish(topic string, msg interface{}) error
	Subscribe(topic string, actor Actor) error
}

type Supervisor

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

func NewSupervisor

func NewSupervisor(ctx context.Context) *Supervisor

NewSupervisor creates a new supervisor with an optional timeout

func (*Supervisor) GetID

func (s *Supervisor) GetID() uuid.UUID

func (*Supervisor) Stop

func (s *Supervisor) Stop()

Stop gracefully stops all actors and nested supervisors

func (*Supervisor) SuperviseActor

func (s *Supervisor) SuperviseActor(actor Actor)

SuperviseActor adds an actor to the supervisor and starts it

func (*Supervisor) SuperviseSupervisor

func (s *Supervisor) SuperviseSupervisor(subSupervisor *Supervisor)

SuperviseSupervisor adds a nested supervisor (creating a hierarchy)

func (*Supervisor) Wait

func (s *Supervisor) Wait()

Wait blocks until the supervisor is stopped

type SupervisorActorResult

type SupervisorActorResult struct {
	Action int
	Result *ActorResult
}

type SupervisorMonitor

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

SupervisorMonitor manages communication between supervisors

func NewSupervisorMonitor

func NewSupervisorMonitor(s *Supervisor) *SupervisorMonitor

NewSupervisorMonitor creates a new monitor for supervisors

func (*SupervisorMonitor) GetInboundChannel

func (m *SupervisorMonitor) GetInboundChannel() chan *SupervisorActorResult

func (*SupervisorMonitor) GetOutboundChannel

func (m *SupervisorMonitor) GetOutboundChannel() chan *SupervisorActorResult

func (*SupervisorMonitor) SetOutboundChannel

func (m *SupervisorMonitor) SetOutboundChannel(outbound chan *SupervisorActorResult)

Jump to

Keyboard shortcuts

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