queue

package module
v0.2.1 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

queue

chefgo queue module.

Documentation

Index

Constants

View Source
const (
	NAME = "QUEUE"
)

Variables

This section is empty.

Functions

func Configure

func Configure(cfg Map)

Configure 更新配置

func DeferredEnqueue added in v0.1.0

func DeferredEnqueue(name string, value Map, delay time.Duration) error

func DeferredEnqueueTo added in v0.1.0

func DeferredEnqueueTo(conn, name string, value Map, delay time.Duration) error

func Enqueue

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

func EnqueueTo added in v0.0.3

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

func Go

func Go()

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

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(Info) error

	Start() error
	Stop() error

	Enqueue(name string, data []byte) error
	DeferredEnqueue(name string, data []byte, delay time.Duration) error
}

Connect 连接

type Context

type Context struct {
	chef.Meta

	// 以下几个字段必须独立
	// 要不然,Invoke的时候,会被修改掉
	Name    string
	Config  *Queue
	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) Finish added in v0.1.0

func (ctx *Context) Finish()

func (*Context) Found

func (ctx *Context) Found()

func (*Context) Next

func (ctx *Context) Next()

func (*Context) Retry

func (ctx *Context) Retry(delays ...time.Duration)

返回延迟(相当于重试)

type Delay added in v0.1.0

type Delay = []time.Duration

type Delegate

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

type Driver

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

Driver 数据驱动

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 Info added in v0.1.0

type Info struct {
	Name   string
	Thread int
	Retry  int
	Delay  []time.Duration
}

type Instance

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

func (*Instance) Serve

func (this *Instance) Serve(req Request) Response

func (*Instance) Submit added in v0.1.2

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) DeferredEnqueue added in v0.1.0

func (this *Module) DeferredEnqueue(name string, value Map, delay time.Duration) error

func (*Module) DeferredEnqueueTo added in v0.1.0

func (this *Module) DeferredEnqueueTo(conn, name string, value Map, delay time.Duration) error

func (*Module) Driver

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

Driver 注册驱动

func (*Module) Enqueue

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

func (*Module) EnqueueTo added in v0.0.3

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

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

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

直接使用另外注册,是为了方便alias被替换 要不然有可能会重名,在别名里重名

func (*Module) Register

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

func (*Module) Terminate

func (this *Module) Terminate()

type Queue

type Queue 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"`

	//Option
	Thread int `json:"thread"`
	// Attempt  int             `json:"attempt"`
	// Interval time.Duration   `json:"interval"`
	Retry int             `json:"retry"`
	Delay []time.Duration `json:"delay"`
}

type Request added in v0.1.0

type Request struct {
	Name      string
	Data      []byte
	Attempt   int
	Timestamp time.Time
}

type Response added in v0.1.0

type Response struct {
	Retry bool
	Delay time.Duration
}

Jump to

Keyboard shortcuts

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