behaviorx

package
v0.0.52 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteBehaviors

func ExecuteBehaviors(key string)

func RegisterBehavior

func RegisterBehavior(key string, behavior *Behavior)

func Shutdown

func Shutdown(code string, context context.Context) error

func Startup

func Startup(code, port string) error

Types

type Action

type Action struct {
	Topic     string                                                              `json:"name"`    // 用于标记Topic的名称
	Deliver   map[string]interface{}                                              `json:"deliver"` // 用于传递消息的内容
	Assembler func(msg *messagex.Message) (map[string]interface{}, *errors.Error) // 用于组装消息内容
}

Action and Event are the two main types of behaviors in the system.

func (*Action) DeliverCopy

func (a *Action) DeliverCopy() map[string]interface{}

copy Deliver

type Behavior

type Behavior struct {
	SubID  uint64    // 标记订阅的ID
	Name   string    `json:"name"` // 用于标记行为的名称
	First  *Behavior // 用于标记链路的第一个行为
	Action Action    `json:"action"` // 用于标记行为的动作
	Result Result    `json:"result"` // 用于标记行为的结果
	Next   *Behavior // 用于标记链路的下一个行为

}

func Create

func Create(b *Behavior) *Behavior

func (*Behavior) DeepCopy

func (b *Behavior) DeepCopy() *Behavior

DeepCopy 创建当前Behavior的深拷贝,包括它的整个Next链

func (*Behavior) Execute

func (b *Behavior) Execute()

func (*Behavior) IsFirst

func (b *Behavior) IsFirst() bool

func (*Behavior) Register

func (b *Behavior) Register(key string)

func (*Behavior) SetNext

func (b *Behavior) SetNext(behavior *Behavior) *Behavior

type Result

type Result struct {
	Topic     string                                            `json:"name"`    // 用于标记Topic的名称
	Filters   map[string]interface{}                            `json:"filters"` // 用于过滤消息的内容
	Validator func(msg *messagex.Message) (bool, *errors.Error) // 用于校验消息内容
}

Jump to

Keyboard shortcuts

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