nsq

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Topics added in v0.5.0

func Topics(hosts []string) ([]string, error)

Types

type Consumer

type Consumer struct {

	// wait group is to make sure all consumers are closed during
	// a shutdown.
	sync.WaitGroup

	// mutex for updating consumer maxInFlight
	sync.Mutex
	// contains filtered or unexported fields
}

func NewConsumer

func NewConsumer(topic, channel string, opt *Option) (*Consumer, error)

func (*Consumer) HandleMessage

func (c *Consumer) HandleMessage(msg *gonsq.Message) error

func (*Consumer) Info added in v0.2.0

func (c *Consumer) Info() info.Consumer

func (*Consumer) Msg

func (c *Consumer) Msg() (msg []byte, done bool, err error)

Msg will block until it receives one and only one message.

Safe to call concurrently. Safe to call after Stop() and if this is the case will simple return done=true.

func (*Consumer) Stop

func (c *Consumer) Stop() error

type Option

type Option struct {
	NSQdAddrs    []string // connects via TCP only
	LookupdAddrs []string // connects via HTTP only

	// if nil then the default nsq logger is used
	Logger *log.Logger

	// default is nsq.LogLevelInfo. Only set if a
	// custom logger is provided.
	LogLvl gonsq.LogLevel
}

Option is used for instantiating an NSQ Consumer or Producer. The Producer will ignore the Topic value.

type Producer

type Producer struct {

	// mutex for hostpool access
	sync.Mutex
	// contains filtered or unexported fields
}

func NewProducer

func NewProducer(opt *Option) (*Producer, error)

func (*Producer) Info added in v0.2.0

func (p *Producer) Info() info.Producer

func (*Producer) Send

func (p *Producer) Send(topic string, msg []byte) error

func (*Producer) Stop

func (p *Producer) Stop() error

Jump to

Keyboard shortcuts

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