nsq

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeDeadLetter

func DecodeDeadLetter(
	encoded []byte,
	visibility management.PayloadVisibility,
) (management.JobRecord, error)

DecodeDeadLetter converts one package-owned NSQ terminal envelope into the backend-neutral management record without exposing NSQ client types.

Types

type Option

type Option interface {
	Apply(*Options)
}

An Option configures a mutex.

func WithAddr

func WithAddr(addr string) Option

WithAddr setup the addr of NSQ

func WithChannel

func WithChannel(channel string) Option

WithChannel setup the channel of NSQ

func WithConnectTimeout

func WithConnectTimeout(timeout time.Duration) Option

WithConnectTimeout bounds NSQ producer and consumer connection attempts.

func WithDeadLetter

func WithDeadLetter(topic string, maxAttempts uint16) Option

WithDeadLetter configures the package-owned terminal topic and bounded NSQ delivery-attempt policy.

func WithLogLevel

func WithLogLevel(lvl nsq.LogLevel) Option

WithLogLevel set custom nsq log level

func WithLogger

func WithLogger(l queue.Logger) Option

WithLogger set custom logger

func WithMaxInFlight

func WithMaxInFlight(num int) Option

WithMaxInFlight Maximum number of messages to allow in flight (concurrency knob)

func WithRequestTimeout

func WithRequestTimeout(timeout time.Duration) Option

WithRequestTimeout sets how long Request waits for an NSQ message.

func WithRunFunc

func WithRunFunc(fn func(context.Context, core.TaskMessage) error) Option

WithRunFunc setup the run func of queue

func WithTopic

func WithTopic(topic string) Option

WithTopic setup the topic of NSQ

func WithTouchInterval

func WithTouchInterval(interval time.Duration) Option

WithTouchInterval sets how often an in-flight NSQ message is touched.

type OptionFunc

type OptionFunc func(*Options)

OptionFunc is a function that configures a queue.

func (OptionFunc) Apply

func (f OptionFunc) Apply(option *Options)

Apply calls f(option)

type Options

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

type Worker

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

Worker for NSQ

func NewWorker

func NewWorker(opts ...Option) *Worker

NewWorker for struc

func NewWorkerE

func NewWorkerE(opts ...Option) (*Worker, error)

NewWorkerE creates a worker and returns configuration errors.

func (*Worker) BackendName

func (*Worker) BackendName() string

BackendName identifies NSQ in lifecycle events.

func (*Worker) Queue

func (w *Worker) Queue(job core.TaskMessage) error

Queue send notification to queue

func (*Worker) QueueName

func (w *Worker) QueueName() string

QueueName returns the configured NSQ topic.

func (*Worker) Request

func (w *Worker) Request() (core.TaskMessage, error)

Request fetch new task from queue

func (*Worker) Run

func (w *Worker) Run(ctx context.Context, task core.TaskMessage) error

Run start the worker

func (*Worker) Shutdown

func (w *Worker) Shutdown() error

Shutdown worker

func (*Worker) Stats

func (w *Worker) Stats() *nsq.ConsumerStats

Stats retrieves the current connection and message statistics for a Consumer

Jump to

Keyboard shortcuts

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