leikari

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2021 License: MIT Imports: 11 Imported by: 0

README

leikari

actor framework for Golang

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorType        = reflect.TypeOf((*error)(nil)).Elem()
	ActorContextType = reflect.TypeOf((*ActorContext)(nil)).Elem()
	MessageType      = reflect.TypeOf((*Message)(nil)).Elem()
)
View Source
var (
	ErrUnknownCommand = Errorln("", "unknown command")
)

Functions

func CheckImplements

func CheckImplements(atype reflect.Type, btype reflect.Type) bool

func CheckImplementsOneOf

func CheckImplementsOneOf(atype reflect.Type, types ...reflect.Type) bool

func CheckIn

func CheckIn(ftype reflect.Type, params ...reflect.Type) bool

func CheckOut

func CheckOut(ftype reflect.Type, params ...reflect.Type) bool

func CompareType

func CompareType(atype reflect.Type, btype reflect.Type) bool

func GenerateName added in v0.1.0

func GenerateName() string

func IsActorContextType

func IsActorContextType(gtype reflect.Type) bool

func IsErrorType

func IsErrorType(gtype reflect.Type) bool

func IsMessageType

func IsMessageType(gtype reflect.Type) bool

func MethodByName

func MethodByName(v interface{}, name string) (reflect.Value, bool)

func PostStopFunc

func PostStopFunc(v interface{}) func(ActorContext) error

func PostStopMethod

func PostStopMethod(v interface{}) (reflect.Value, bool)

func PreStartFunc

func PreStartFunc(v interface{}) func(ActorContext) error

func PreStartMethod

func PreStartMethod(v interface{}) (reflect.Value, bool)

func PtrValue

func PtrValue(gvalue reflect.Value) reflect.Value

func ReceiveFunc

func ReceiveFunc(v interface{}) func(ActorContext, Message)

func ReceiveMethod

func ReceiveMethod(v interface{}) (reflect.Value, bool)

Types

type Actor

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

func NewActor

func NewActor(v interface{}, name string) Actor

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 DoneEvent

type DoneEvent struct{}

func Done

func Done() DoneEvent

type Error

type Error struct {
	Code        string `json:"code,omitempty"`
	Message     string `json:"error"`
	Description string `json:"description,omitempty"`
	Status      int    `json:"-"`
}

func Errorf

func Errorf(code string, format string, v ...interface{}) *Error

func Errorln

func Errorln(code string, v ...interface{}) *Error

func MapError

func MapError(code string, err error) *Error

func New

func New(code string, msg string) *Error

func NewOf

func NewOf(code string, err error) *Error

func (*Error) Error

func (e *Error) Error() string

func (*Error) StatusCode

func (e *Error) StatusCode() int

func (*Error) String

func (e *Error) String() string

func (*Error) WithDescription

func (e *Error) WithDescription(desc string) *Error

func (*Error) WithStatusCode

func (e *Error) WithStatusCode(status int) *Error

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, 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
example
countries command

Jump to

Keyboard shortcuts

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