xactor

package
v0.0.0-...-3001dc0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAgentAtDel    error = errors.New("agent at del")
	ErrAgentExist    error = errors.New("agent exists")
	ErrAgentNotExist error = errors.New("agent not exist")
)
View Source
var (
	ErrResponserIsFull  error = errors.New("responser is full")
	ErrResponserClosed  error = errors.New("responser closed")
	ErrResponserTimeout error = errors.New("responser timeout")
)

Functions

func DispatchAgent

func DispatchAgent(am *AgentManager, key string, req any) (int, any, error)

func StopAgentManager

func StopAgentManager(am *AgentManager)

Types

type Agent

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

func NewAgentWithOption

func NewAgentWithOption(opt *AgentOption) *Agent

func (*Agent) Call

func (agent *Agent) Call(req any) (int, any, error)

func (*Agent) DoWork

func (agent *Agent) DoWork(c actor.Context) actor.WorkerStatus

func (*Agent) GetKey

func (agent *Agent) GetKey() string

func (*Agent) Post

func (agent *Agent) Post(req any)

func (*Agent) SetLast

func (agent *Agent) SetLast(t time.Time)

func (*Agent) Start

func (agent *Agent) Start()

func (*Agent) Stop

func (agent *Agent) Stop()

type AgentManager

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

func NewAgentManager

func NewAgentManager() *AgentManager

func NewAgentManagerWithOption

func NewAgentManagerWithOption(opt *AgentManagerOption) *AgentManager

func (*AgentManager) Add

func (am *AgentManager) Add(k string, agent *Agent) error

func (*AgentManager) AtDel

func (am *AgentManager) AtDel(k string) bool

func (*AgentManager) Del

func (am *AgentManager) Del(k string, ag *Agent) bool

func (*AgentManager) DoWork

func (*AgentManager) GetIdlechan

func (am *AgentManager) GetIdlechan() chan any

func (*AgentManager) Len

func (am *AgentManager) Len() int

func (*AgentManager) MarkDel

func (am *AgentManager) MarkDel(k string, expires int64) *Agent

func (*AgentManager) NewAgent

func (am *AgentManager) NewAgent(key string, cb func(*Call)) error

func (*AgentManager) Start

func (am *AgentManager) Start()

func (*AgentManager) Stop

func (am *AgentManager) Stop()

func (*AgentManager) StopAgents

func (am *AgentManager) StopAgents(cb func(agent *Agent) bool)

func (*AgentManager) Val

func (am *AgentManager) Val(k string) (*Agent, error)

type AgentManagerOption

type AgentManagerOption struct {
	Duration time.Duration
	Idlechan chan any
}

type AgentOption

type AgentOption struct {
	Key      string
	CallFn   func(*Call)
	DoneFn   func()
	TimerFn  func()
	Duration time.Duration
	Idlechan chan any
}

type Call

type Call struct {
	Req any
	To  time.Duration

	Code   int
	Resp   any
	RespCh chan any
}

func (*Call) Response

func (call *Call) Response(code int, resp any) error

func (*Call) WaitCall

func (call *Call) WaitCall() (int, any, error)

type Responser

type Responser interface {
	Response(int, any) error
}

Jump to

Keyboard shortcuts

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