nsq

package
v1.12.3 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(nsqd string, lookupd []string, consumers ...Consumer) error

Init 使用默认配置初始化

func InitWithCfg

func InitWithCfg(nsqd string, lookupd []string, cfg *nsq.Config, consumers ...Consumer) (err error)

InitWithCfg 指定配置初始化

func NextAttemptDelay

func NextAttemptDelay(attempts uint16) (delay time.Duration)

NextAttemptDelay 一个帮助方法,用于返回下一次尝试的等待时间

func Publish

func Publish(topic string, msg []byte) error

Publish 同步推送消息到指定Topic

func PublishDelay added in v1.12.2

func PublishDelay(topic string, msg []byte, delay time.Duration) error

PublishDelay 同步推送延迟消息到指定Topic

func SetErrLogger

func SetErrLogger(l *zap.Logger)

SetErrLogger 设置错误日志

Types

type Consumer

type Consumer interface {
	nsq.Handler
	// Topic 指定消费的Topic
	Topic() string
	// Channel 设置消费通道
	Channel() string
	// Attempts 设置重试次数
	Attempts() uint16
	// Config nsq相关配置
	Config() *nsq.Config
}

Consumer nsq消费者接口

type Logger

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

Logger 实现nsq日志接口

func (*Logger) Output

func (l *Logger) Output(calldepth int, s string) error

Output nsq错误输出

Jump to

Keyboard shortcuts

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