🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

github.com/ibmendoza/go-queue

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/ibmendoza/go-queue

v0.0.0-20151005053519-42b12dcfde3b
Source
Go
Version published
Created
Source

queue

The queue package wraps NSQ consumers to help reduce the amount of boilerplate that each program has to implement to get rolling. It does not attempt to abstract NSQ away entirely.

View the go-nsq documentation for configuration options.

Example

c := queue.NewConsumer("events", "ingestion")

c.Set("nsqd", ":5001")
c.Set("concurrency", 15)
c.Set("max_attempts", 10)
c.Set("max_in_flight", 150)
c.Set("default_requeue_delay", "15s")

c.Start(nsq.HandlerFunc(func(msg *nsq.Message) error {
  // do something
  return nil
}))

Usage

type Consumer

type Consumer struct {}

Consumer convenience layer.

func NewConsumer

func NewConsumer(topic, channel string) *Consumer

NewConsumer returns a new consumer of topic and channel.

func (*Consumer) Set

func (c *Consumer) Set(option string, value interface{})

Set option to value, any error will be returned in .Start().

Custom options implemented:

- `topic` consumer topic
- `channel` consumer channel
- `nsqd` nsqd address
- `nsqds` nsqd addresses
- `nsqlookupd` nsqlookupd address
- `nsqlookupds` nsqlookupd addresses
- `concurrency` concurrent handlers [1]

func (*Consumer) SetLogger

func (c *Consumer) SetLogger(log logger, level nsq.LogLevel)

SetLogger replaces the default logger.

func (*Consumer) Start

func (c *Consumer) Start(handler nsq.Handler) error

Start consumer with handler.

func (*Consumer) Stop

func (c *Consumer) Stop() error

Stop and wait.

License

MIT

FAQs

Package last updated on 05 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts