consumer

package module
v0.2.2-0...-d2a05ab Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: MIT Imports: 6 Imported by: 0

README

RIP

Was used by old evensource modules, which were suporessed by https://github.com/replaygaming/sse

Consumer Go package

This wraps the message consumer logic into a small package. Currently only contains a google pubsub backend but it can be extended for other backends in the future

Build

go build

Yes. That simple

Test

With a pubsub emulator running, then... Start a pubsub emulator with

gcloud beta emulators pubsub start

Then initialize the environment and run the tests with

eval $(gcloud beta emulators pubsub env-init)
go test

Once again, yes... that simple :)

Documentation

godoc github.com/replaygaming/consumer

BOOM 💥

Documentation

Overview

Consumer package provides a very thin abstraction around message consuming. It assumes a simple message and consumer interface that can consume messages and acknowledge them

Index

Constants

View Source
const ContextDuration time.Duration = 30 * time.Second

Variables

This section is empty.

Functions

This section is empty.

Types

type Consumer

type Consumer interface {
	// Creates a channel that will receive messages. Each message should be
	// acknowledged once you're done with it through the Done() method on the
	// message
	Consume() (chan Message, error)

	// Signals the backend to remove this consumer
	Remove() error
}

Represents a consumer

func NewConsumer

func NewConsumer(topicName string, subscriptionName string) Consumer

Creates a new consumer

type Message

type Message interface {
	// Returns the data inside of the message
	Data() []byte
	// Marks that the message has been processed. If ack is true, it also
	// acknowledges that the message should no longer be received.
	Done(ack bool)
}

Represents a message

Jump to

Keyboard shortcuts

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