bus

package module
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2022 License: MIT Imports: 8 Imported by: 2

README

bus

chefgo bus module.

Documentation

Index

Constants

View Source
const (
	NAME = "BUS"
)

Variables

This section is empty.

Functions

func Configure

func Configure(cfg Map)

Configure 更新配置

func Go

func Go()

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

func Ready

func Ready()

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

func Register

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

Register 开放给外

Types

type Bridge

type Bridge struct{}

func (*Bridge) Request

func (this *Bridge) Request(meta chef.Metadata, timeout time.Duration) (*chef.Echo, error)

type Callback

type Callback = func([]byte, error)

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 string) error

	Start() error
	Stop() error

	Request(name string, data []byte, timeout time.Duration) ([]byte, error)
}

Connect 连接

type Context

type Context struct {
	chef.Meta

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

	Type string
	Body Map
	// 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(name string, data []byte, callback Callback)
}

type Driver

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

Driver 数据驱动

type Filter

type Filter struct {
	Name     string  `json:"name"`
	Text     string  `json:"text"`
	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, next Callback)

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) 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) Register

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

func (*Module) Request

func (this *Module) Request(meta chef.Metadata, timeout time.Duration) (*chef.Echo, error)

func (*Module) Service

func (module *Module) Service(name string, config chef.Service, override bool)

func (*Module) Terminate

func (this *Module) Terminate()

Jump to

Keyboard shortcuts

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