pubsub

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package pubsub contains types to deal with subscriptions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PubSub

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

PubSub deals with subscribing and publishing messages.

func New

func New() *PubSub

New creates a new PubSub.

func (*PubSub) Publish

func (p *PubSub) Publish(msgType string, msg interface{})

Publish will publish a message of the given type to all subscribers for that type.

func (*PubSub) Subscribe

func (p *PubSub) Subscribe(ctx context.Context, msgType string, fn func(interface{}))

Subscribe register a function that will receive messages of the given type. To unsubscribe the context must be closed.

Jump to

Keyboard shortcuts

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