pubsub

package module
v0.0.0-...-e6824c6 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2017 License: BSD-3-Clause Imports: 3 Imported by: 50

README

Go package provides a common interface for publish-subscriber messaging.

Documentation:

    http://godoc.org/github.com/cncd/pubsub
    http://godoc.org/github.com/cncd/pubsub/gcp

Documentation

Overview

Package pubsub implements a publish-subscriber messaging system.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("topic not found")

ErrNotFound is returned when the named topic does not exist.

Functions

This section is empty.

Types

type Message

type Message struct {
	// ID identifies this message.
	ID string `json:"id,omitempty"`

	// Data is the actual data in the entry.
	Data []byte `json:"data"`

	// Labels represents the key-value pairs the entry is lebeled with.
	Labels map[string]string `json:"labels,omitempty"`
}

Message defines a published message.

type Publisher

type Publisher interface {
	// Create creates the named topic.
	Create(c context.Context, topic string) error

	// Publish publishes the message.
	Publish(c context.Context, topic string, message Message) error

	// Subscribe subscribes to the topic. The Receiver function is a callback
	// function that receives published messages.
	Subscribe(c context.Context, topic string, receiver Receiver) error

	// Remove removes the named topic.
	Remove(c context.Context, topic string) error
}

Publisher defines a mechanism for communicating messages from a group of senders, called publishers, to a group of consumers.

func New

func New() Publisher

New creates an in-memory publisher.

type Receiver

type Receiver func(Message)

Receiver receives published messages.

Directories

Path Synopsis
gcp

Jump to

Keyboard shortcuts

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