goller

package module
v0.0.0-...-30a2682 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2016 License: MIT Imports: 5 Imported by: 1

README

goller

CircleCI GoDoc

A Golang AWS SQS long poller.

Installation

go get github.com/wealthsimple/goller

Usage

import (
	"fmt"
	"github.com/wealthsimple/goller"
	"log"
	"os"
)

type testStruct struct {
	goller.Handler
}

func (t testStruct) Handle(message *string) {
	fmt.Printf("%+v\n", *message)
}

func main() {
	l := log.New(os.Stdout, "goller: ", log.Lshortfile|log.LstdFlags)
	config := goller.Configuration{
		WaitTimeSeconds:     20,
		VisibilityTimeout:   10,
		MaxNumberOfMessages: 1,
		Region:              "us-east-1",
		QueueURL:            os.Getenv("QUEUE_URL"),
		AccessKeyID:         os.Getenv("AWS_ACCESS_KEY_ID"),
		SecretKey:           os.Getenv("AWS_SECRET_KEY"),
	}

	t := new(testStruct)
	sqs := goller.NewSqsPoller(config, t, l)
	sqs.Poll()
}
  • See goller_integration_test.go for more details

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	WaitTimeSeconds     int64
	VisibilityTimeout   int64
	MaxNumberOfMessages int64
	Region              string
	QueueURL            string
	AccessKeyID         string
	SecretKey           string
	// contains filtered or unexported fields
}

Configuration is a struct containing options to construct a poller with

type Handler

type Handler interface {
	Handle(message *string)
}

Handler is the interface that will handle all SQS messages

type SqsQueue

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

SqsQueue is the structure containing config and session information for a particular poller

func NewSqsPoller

func NewSqsPoller(c Configuration, h Handler, l *log.Logger) *SqsQueue

NewSqsPoller returns a new sqs poller for a given configuration and handler

func (*SqsQueue) Poll

func (s *SqsQueue) Poll()

Poll long polls the sqs queue (provided that the WaitTimeSeonds is set in the config and > 0)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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