nsqkeepalive

package module
v0.0.0-...-15afd0e Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 License: MIT Imports: 2 Imported by: 0

README

NSQ Keep Alive

Go Reference

By default NSQ will requeue a message if there is no response after 1 minute. This library will touch the message on a regular interval (I use 50 seconds) to let NSQ know it's still being processed.

Example

package main

import (
  "github.com/bryanaustin/nsqkeepalive"
  "github.com/nsqio/go-nsq"
  "time"
)

func main() {
  nsqconfig := nsq.NewConfig()
  consumer, err = nsq.NewConsumer("topic", "channel", nsqconfig)
  if err != nil {
    // Handle err
  }
  handlerobj := nsq.HandlerFunc(handler)
  wrappedhandler := nsqkeepalive.Handler(time.Second * 50, handlerobj)
  consumer.AddHandler(wrappedhandler)
  err = consumer.ConnectToNSQLookupd("localhost:4161")
  if err != nil {
    // Handle err
  }
  // ...
}

func handler(m *nsq.Message) error {
  // This message will be touched until it returns
}

Documentation

Overview

A handler wrapper for keeping alive (touching) NSQ messages on a fixed interval.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(i time.Duration, h nsq.Handler) nsq.Handler

Handler is a continence method for creating HandlerWrapper

Types

type HandlerWrapper

type HandlerWrapper struct {
	Interval time.Duration
	Child    nsq.Handler
}

HandlerWrapper implements nsq.Handler and touches the message on the specified interval

func (HandlerWrapper) HandleMessage

func (h HandlerWrapper) HandleMessage(m *nsq.Message) error

HandleMessage implements nsq.Handler for HandlerWrapper

Jump to

Keyboard shortcuts

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