leikari

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2021 License: MIT Imports: 11 Imported by: 0

README

leikari

actor framework for Golang

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateName added in v0.1.0

func GenerateName() string

Types

type Actor

type Actor struct {
	Name      string
	OnReceive func(ActorContext, Message)
	OnStart   func(ActorContext) error
	OnStop    func(ActorContext) error
	Async     bool
}

func (Actor) ActorName added in v0.1.0

func (a Actor) ActorName() string

func (Actor) AsyncActor

func (a Actor) AsyncActor() bool

func (Actor) PostStop

func (a Actor) PostStop(ctx ActorContext) error

func (Actor) PreStart

func (a Actor) PreStart(ctx ActorContext) error

func (Actor) Receive

func (a Actor) Receive(ctx ActorContext, msg Message)

type ActorContext

type ActorContext interface {
	ActorExecutor
	Name() string
	Log() Logger
	Done() <-chan struct{}

	Self() Ref

	Handler() ActorHandler

	Set(string, interface{})
	Add(string, interface{}) error
	Replace(string, interface{}) error
	Get(string) (interface{}, bool)
}

type ActorExecutor

type ActorExecutor interface {
	Execute(Receiver, ...Option) (Ref, error)
}

type ActorHandler

type ActorHandler interface {
	Pusher
	ActorHandlerExecutor
	Name() string
	Close()

	Root() ActorHandler
	Parent() (ActorHandler, bool)
	System() System
	Log() Logger

	Child(string) (ActorHandler, bool)
	Children() []ActorHandler

	CreateRef() Ref

	Cache() Cache
}

type ActorHandlerExecutor

type ActorHandlerExecutor interface {
	ExecuteHandler(Receiver, ...Option) (ActorHandler, error)
}

type AsyncActor

type AsyncActor interface {
	AsyncActor() bool
}

type Cache

type Cache interface {
	Set(key string, value interface{})
	Add(key string, value interface{}) error
	Replace(key string, value interface{}) error
	Get(key string) (interface{}, bool)
}

func NewCache

func NewCache() Cache

type HandlerSettings added in v0.1.0

type HandlerSettings struct {
	Name         string
	WorkerPool   int
	MessageQueue int
	Log          Logger
	Async        bool
}

type Logger

type Logger interface {
	ForName(string) Logger

	Debug(...interface{})
	Info(...interface{})
	Warn(...interface{})
	Error(...interface{})
	Fatal(...interface{})
	Panic(...interface{})

	Debugf(string, ...interface{})
	Infof(string, ...interface{})
	Warnf(string, ...interface{})
	Errorf(string, ...interface{})
	Fatalf(string, ...interface{})
	Panicf(string, ...interface{})
}

func Empty

func Empty() Logger

func NewSysLogger added in v0.1.0

func NewSysLogger(logger log.Logger) Logger

func SysLogger added in v0.1.0

func SysLogger() Logger

type Message

type Message interface {
	Value() interface{}
	Reply(interface{})
}

func Request

func Request(reply chan<- interface{}, v interface{}) Message

func Send

func Send(v interface{}) Message

type NamedActor added in v0.1.0

type NamedActor interface {
	ActorName() string
}

type Option

type Option struct {
	Name  string
	Value interface{}
}

func Async

func Async() Option

func Log added in v0.1.0

func Log(log Logger) Option

func MessageQueue

func MessageQueue(size int) Option

func Name added in v0.1.0

func Name(name string) Option

func NoSignature

func NoSignature() Option

func WorkerPool

func WorkerPool(size int) Option

func (Option) Bool

func (opt Option) Bool() bool

func (Option) Float32

func (opt Option) Float32() (float32, bool)

func (Option) Float64

func (opt Option) Float64() (float64, bool)

func (Option) Int

func (opt Option) Int() (int, bool)

func (Option) Int8

func (opt Option) Int8() (int8, bool)

func (Option) Int16

func (opt Option) Int16() (int16, bool)

func (Option) Int32

func (opt Option) Int32() (int32, bool)

func (Option) Int64

func (opt Option) Int64() (int64, bool)

func (Option) String

func (opt Option) String() string

func (Option) Uint

func (opt Option) Uint() (uint, bool)

func (Option) Uint8

func (opt Option) Uint8() (uint8, bool)

func (Option) Uint16

func (opt Option) Uint16() (uint16, bool)

func (Option) Uint32

func (opt Option) Uint32() (uint32, bool)

func (Option) Uint64

func (opt Option) Uint64() (uint64, bool)

type Pusher added in v0.1.0

type Pusher interface {
	Push(Message) error
}

type Receiver

type Receiver interface {
	Receive(ActorContext, Message)
}

type ReceiverFunc

type ReceiverFunc func(ActorContext, Message)

func (ReceiverFunc) Receive

func (f ReceiverFunc) Receive(ctx ActorContext, msg Message)

type Ref

type Ref interface {
	Send(interface{}) error

	RequestChan(interface{}) <-chan interface{}
	Request(interface{}) (interface{}, error)
	RequestContext(context.Context, interface{}) (interface{}, error)
}

func NewRef added in v0.1.0

func NewRef(pusher Pusher) Ref

type ServiceExecutor

type ServiceExecutor interface {
	ExecuteService(Receiver, ...Option) (ActorHandler, error)
}

type Startable

type Startable interface {
	PreStart(ActorContext) error
}

type Stopable

type Stopable interface {
	PostStop(ActorContext) error
}

type System

type System interface {
	ActorExecutor
	ServiceExecutor
	Log() Logger
	Terminate()
	Terminated() <-chan int
	Run()

	Timer(time.Duration, func(time.Time)) *time.Timer
	Ticker(time.Duration, func(time.Time)) *time.Ticker
}

func NewSystem

func NewSystem(opts ...Option) System

type SystemSettings

type SystemSettings struct {
	NoSignature bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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