Help us shape the future of Go! Take the 2026 Go Developer Survey

nsqclient

package module
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2019 License: MIT Imports: 14 Imported by: 0

README

nsqclient

nsq client for golang

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NsqGroups = make(map[string][]INsqHandler)

Functions

func Client

func Client(name ...string) (pool.Pool, bool)

func Connect

func Connect(configs map[string]Config)

func NewDebugError

func NewDebugError(text string) error

func NewProducer

func NewProducer(addr string) (*nsq.Producer, error)

CreateNSQProducer create nsq producer

func NewProducerPool

func NewProducerPool(addr string, initSize, maxSize int) (pool.Pool, error)

CreateNSQProducerPool create a nwq producer pool

func Publish

func Publish(topic string, body []byte, nsqName ...string) error

func Register

func Register(h INsqHandler, group string)

func Run

func Run(group string, ctx context.Context, conf Config)

Types

type Config

type Config struct {
	Host     string `json:"host"`
	Port     string `json:"port"`
	InitSize int    `toml:"init_size" json:"init_size"`
	MaxSize  int    `toml:"max_size" json:"max_size"`
}

type HandleFunc

type HandleFunc func(debug *debug.DebugTag, log logger.ILogger, message *nsq.Message) error

type INsqHandler

type INsqHandler interface {
	GetTopic() string
	GetChannel() string
	SetHandle(HandleFunc)
	GetHandle() HandleFunc
	SetShouldRequeue(fn func(message *nsq.Message) (bool, time.Duration))
	GetShouldRequeue(message *nsq.Message) (bool, time.Duration)
	GetMaxAttepts() uint16
	Group(group string)
	IsOpenChannelTopic() bool
	GetChannelTopic() string
	GetSize() int
	Init(fn func(ctx context.Context))
	RunInit(ctx context.Context)
}

type NsqConsumer

type NsqConsumer struct {
	Consumer *nsq.Consumer
	Handlers []nsq.Handler
	// contains filtered or unexported fields
}

func NewNsqConsumer

func NewNsqConsumer(ctx context.Context, topic, channel string, options ...func(*nsq.Config)) (*NsqConsumer, error)

func (*NsqConsumer) AddHandler

func (n *NsqConsumer) AddHandler(handler nsq.Handler)

func (*NsqConsumer) Run

func (n *NsqConsumer) Run(conf Config)

type NsqHandler

type NsqHandler struct {
	Topic            string
	Channel          string
	Size             int
	MaxAttepts       uint16
	OpenChannelTopic bool // 是否开启独立的topic [Topic.Channel]
	Handler          HandleFunc
	// contains filtered or unexported fields
}

func NewNsqHandler

func NewNsqHandler(options ...func(*NsqHandler)) *NsqHandler

func (*NsqHandler) GetChannel

func (h *NsqHandler) GetChannel() string

func (*NsqHandler) GetChannelTopic

func (h *NsqHandler) GetChannelTopic() string

func (*NsqHandler) GetHandle

func (h *NsqHandler) GetHandle() HandleFunc

func (*NsqHandler) GetMaxAttepts

func (h *NsqHandler) GetMaxAttepts() uint16

func (*NsqHandler) GetShouldRequeue

func (h *NsqHandler) GetShouldRequeue(message *nsq.Message) (bool, time.Duration)

func (*NsqHandler) GetSize

func (h *NsqHandler) GetSize() int

func (*NsqHandler) GetTopic

func (h *NsqHandler) GetTopic() string

func (*NsqHandler) Group

func (h *NsqHandler) Group(group string)

func (*NsqHandler) Init added in v1.0.1

func (h *NsqHandler) Init(fn func(ctx context.Context))

func (*NsqHandler) IsOpenChannelTopic

func (h *NsqHandler) IsOpenChannelTopic() bool

func (*NsqHandler) RunInit added in v1.0.1

func (h *NsqHandler) RunInit(ctx context.Context)

func (*NsqHandler) SetHandle

func (h *NsqHandler) SetHandle(fn HandleFunc)

func (*NsqHandler) SetShouldRequeue

func (h *NsqHandler) SetShouldRequeue(fn func(message *nsq.Message) (bool, time.Duration))

Directories

Path Synopsis
Package pool implements a pool of net.Conn interfaces to manage and reuse them.
Package pool implements a pool of net.Conn interfaces to manage and reuse them.

Jump to

Keyboard shortcuts

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