Documentation ¶
Overview ¶
Package xmq 是为了创建一个统一的队列接口,以便切换队列服务之后可以不改业务代码 只需要修改配置内容和创建部分变量即可
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { // 发布消息 Pub(topic string, payload interface{}) error // 延迟发布消息 Delay(topic string, payload interface{}, delay time.Duration) error // 订阅 Sub(topic, channel string, f HandlerFunc) // 创建主题 CreateTopic(topic string) error // 清理网络资源 Close() }
Client xobj client
type Config ¶
type Config struct { PubHost string `default:"nsqd"` PubTCP string `default:"4150"` PubHTTP string `default:"4151"` SubHost string `default:"nsqlookupd"` SubTCP string `default:"4160"` SubHTTP string `default:"4161"` }
Config 配置 兼容各种服务
type Context ¶
type Context interface { // Bind binds the payload body into provided type `i`. The default binder // is based on json. Bind(i interface{}) error // Data show the origin payload data body in message Data() []byte // String convert the origin payload data body to string String() string }
Context 继承了队列接收消息后的上下文,包括消息内容和对消息的一些控制。
type LogrusLogger ¶
type LogrusLogger struct{}
LogrusLogger is an adaptor between the weird go-nsq Logger and our standard logrus logger.
func NewLogrusLogger ¶
func NewLogrusLogger() (logger LogrusLogger, level nsq.LogLevel)
NewLogrusLogger returns a new LogrusLogger and the current log level. This is a format to easily plug into nsq.SetLogger.
func NewLogrusLoggerAtLevel ¶
func NewLogrusLoggerAtLevel(l logrus.Level) (logger LogrusLogger, level nsq.LogLevel)
NewLogrusLoggerAtLevel returns a new LogrusLogger with the provided log level mapped to nsq.LogLevel for easily plugging into nsq.SetLogger.
Click to show internal directories.
Click to hide internal directories.