consumer

package
v0.0.0-...-18de4b0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultRetryTimes = 3

Variables

This section is empty.

Functions

func DefaultIsRetry

func DefaultIsRetry(msg interface{}, failTimes int) bool

Types

type Consumer

type Consumer interface {
	AddHandler(handlers ...Handler)
	Run()
	Close()
}

type Context

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

func GenerateCTXByByte

func GenerateCTXByByte(ctx context.Context, b []byte, msgType message.MsgType) (Context, error)

func (*Context) BindJson

func (ctx *Context) BindJson(obj any) error

func (*Context) Deadline

func (ctx *Context) Deadline() (deadline time.Time, ok bool)

func (*Context) Done

func (ctx *Context) Done() <-chan struct{}

func (*Context) Err

func (ctx *Context) Err() error

func (*Context) Reset

func (ctx *Context) Reset()

func (*Context) Value

func (ctx *Context) Value(key any) any

type Handler

type Handler struct {
	Topic      string
	Key        string
	Handle     func(ctx Context) error
	PoolSize   int
	Callback   func(msg any, err error)
	RetryTimes int
	IsRetry    IsRetry
	MsgType    message.MsgType
}

type IsRetry

type IsRetry func(msg any, failTimes int) bool

func IsRetryByFailTimes

func IsRetryByFailTimes(ft int) IsRetry

type RealHandler

type RealHandler struct {
	Handle   func(msg any) error
	Callback func(msg any, err error)
	IsRetry  IsRetry
	GP       *gp.Pool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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