event

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: MIT Imports: 8 Imported by: 4

README

event

chefgo event module.

Documentation

Index

Constants

View Source
const (
	NAME = "EVENT"
)

Variables

This section is empty.

Functions

func Configure

func Configure(cfg Map)

Configure 更新配置

func Go

func Go()

Go 直接开跑 此方法只单独使用模块时用

func Notify added in v0.0.3

func Notify(name string, values ...Map) error

func NotifyTo added in v0.1.1

func NotifyTo(conn, name string, values ...Map) error

func Ready

func Ready()

Ready 准备运行 此方法只单独使用模块时用

func Register

func Register(name string, value Any, overrides ...bool)

Register 开放给外

Types

type Config

type Config struct {
	Driver  string
	Codec   string
	Weight  int
	Prefix  string
	Setting Map
}

type Configs

type Configs map[string]Config

type Connect

type Connect interface {
	Open() error
	Health() (Health, error)
	Close() error

	Register(name, group string) error

	Start() error
	Stop() error

	Notify(name string, data []byte) error
}

Connect 连接

type Context

type Context struct {
	chef.Meta

	// 以下几个字段必须独立
	// 要不然,Invoke的时候,会被修改掉
	Name    string
	Config  *Event
	Setting Map

	Value  Map
	Args   Map
	Locals Map

	Body Any
	// contains filtered or unexported fields
}

func (*Context) Denied

func (ctx *Context) Denied(res Res)

func (*Context) Erred

func (ctx *Context) Erred(res Res)

func (*Context) Failed

func (ctx *Context) Failed(res Res)

func (*Context) Found

func (ctx *Context) Found()

func (*Context) Next

func (ctx *Context) Next()

type Delegate

type Delegate interface {
	Serve(string, []byte)
}

type Driver

type Driver interface {
	Connect(*Instance) (Connect, error)
}

Driver 数据驱动

type Event

type Event struct {
	Name     string   `json:"name"`
	Text     string   `json:"text"`
	Alias    []string `json:"alias"`
	Nullable bool     `json:"-"`
	Args     Vars     `json:"args"`
	Setting  Map      `json:"-"`
	Coding   bool     `json:"-"`

	Action  ctxFunc   `json:"-"`
	Actions []ctxFunc `json:"-"`

	// 路由单独可定义的处理器
	Found  ctxFunc `json:"-"`
	Error  ctxFunc `json:"-"`
	Failed ctxFunc `json:"-"`
	Denied ctxFunc `json:"-"`

	Connect string `json:"connect"`
	Group   bool   `json:"group"`
	// contains filtered or unexported fields
}

type Filter

type Filter struct {
	Name     string  `json:"name"`
	Text     string  `json:"text"`
	Serve    ctxFunc `json:"-"`
	Request  ctxFunc `json:"-"`
	Execute  ctxFunc `json:"-"`
	Response ctxFunc `json:"-"`
}

Filter 拦截器

type Handler

type Handler struct {
	Name   string  `json:"name"`
	Text   string  `json:"text"`
	Found  ctxFunc `json:"-"`
	Error  ctxFunc `json:"-"`
	Failed ctxFunc `json:"-"`
	Denied ctxFunc `json:"-"`
}

Handler 处理器

type Health

type Health struct {
	Workload int64
}

type Instance

type Instance struct {
	Name   string
	Config Config
	// contains filtered or unexported fields
}

func (*Instance) Serve

func (this *Instance) Serve(name string, data []byte)

收到消息 加入协助程池

func (*Instance) Submit added in v0.1.1

func (this *Instance) Submit(next func())

type Module

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

func (*Module) Config

func (this *Module) Config(name string, config Config, override bool)

func (*Module) Configs

func (this *Module) Configs(config Configs, override bool)

func (*Module) Configure

func (this *Module) Configure(global Map)

func (*Module) Connect

func (this *Module) Connect()

func (*Module) Driver

func (module *Module) Driver(name string, driver Driver, override bool)

Driver 注册驱动

func (*Module) Event

func (module *Module) Event(name string, config Event, override bool)

func (*Module) Filter

func (module *Module) Filter(name string, config Filter, override bool)

Filter 注册 拦截器

func (*Module) Handler

func (module *Module) Handler(name string, config Handler, override bool)

Handler 注册 处理器

func (*Module) Initialize

func (this *Module) Initialize()

func (*Module) Launch

func (this *Module) Launch()

func (*Module) Notice

func (module *Module) Notice(name string, config Notice, override bool)

Notice 注册 预告

func (*Module) Notify added in v0.0.3

func (this *Module) Notify(name string, values ...Map) error

Publish 发起消息

func (*Module) NotifyTo added in v0.1.1

func (this *Module) NotifyTo(conn, name string, values ...Map) error

notify 指定连接发起消息

func (*Module) Register

func (this *Module) Register(name string, value Any, override bool)

func (*Module) Terminate

func (this *Module) Terminate()

type Notice

type Notice struct {
	Name     string `json:"name"`
	Text     string `json:"text"`
	Nullable bool   `json:"-"`
	Args     Vars   `json:"args"`
}

Notice 通知,表示当前节点会发出的事件预告 比如,支付模块,可能会发布 pay.Success 之类的一系列的支付完成的事件 在集群模式下,应该会把节点的notice写入集群节点信息下 这样方便,生成分布式的文档,知道哪些节点会发布哪些通知出来

Jump to

Keyboard shortcuts

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