mqwrapper

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compress

func Compress(data []byte) ([]byte, error)

func Decompress

func Decompress(compressed []byte) ([]byte, error)

Types

type Config

type Config struct {
	// Ready 协调各组件之间的状态,当一切就绪之后,Ready将可读,此时该组件开始对外释放能力
	Ready <-chan struct{}

	MQUrl string

	// 生产者配置
	EnableProducer       bool
	ProducerExchange     string
	ProducerExchangeKind string
	ProducerQueue        string
	ProducerRouteKey     string

	// 消费者配置
	EnableConsumer       bool
	ConsumerExchange     string
	ConsumerExchangeKind string
	ConsumerQueue        string
	ConsumerRouteKey     string

	// 日志写入,如果为空将不记录日志
	Debug LogWriter
	Info  LogWriter
	Warn  LogWriter
	Error LogWriter
}

type LogWriter

type LogWriter interface {
	Println(format string, v ...interface{})
}

type MQWrapper

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

func New

func New() *MQWrapper

func (*MQWrapper) Close

func (w *MQWrapper) Close() error

func (*MQWrapper) Open

func (w *MQWrapper) Open(wrapperId string, conf *Config) error

func (*MQWrapper) Post

func (w *MQWrapper) Post(actionKey int32, msg []byte, retry int) error

func (*MQWrapper) RegistActionHandler

func (w *MQWrapper) RegistActionHandler(actionKey int32, f MsgHandler) error

func (*MQWrapper) SetEncoder

func (w *MQWrapper) SetEncoder(e MsgEncoder)

func (*MQWrapper) ValidateConf

func (w *MQWrapper) ValidateConf(conf *Config) error

type MsgEncoder

type MsgEncoder interface {
	Encode(actionKey int32, msgBody []byte) ([]byte, error)
	Decode(b []byte) (actionKey int32, msgBody []byte, err error)
}

func DefaultEncoder

func DefaultEncoder() MsgEncoder

type MsgHandler

type MsgHandler func(actionKey int32, msg []byte) error

Jump to

Keyboard shortcuts

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