topic

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

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

Go to latest
Published: Jul 29, 2013 License: MIT Imports: 1 Imported by: 23

README

Go library for in-process single-topic pub-sub

This library is especially aimed at situations where consumers may disappear at any time.

Use the Go import path

github.com/tv42/topic

Documentation at http://godoc.org/github.com/tv42/topic

Documentation

Overview

Package topic provides a publish-subscribe mechanism where consumers may disappear at any time.

Each Topic is exactly that, a single topic. There is no filtering of messages or such functionality on this level. For example, you could create a new Topic for each chat room on your chat server, with every browser instance using an WebSockets API to Register on every room the user wants to follow.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Topic

type Topic struct {
	// Producer sends messages on this channel. Close the channel
	// to shutdown the topic.
	Broadcast chan<- interface{}
	// contains filtered or unexported fields
}

Topic is a pub-sub mechanism where consumers can Register to receive messages sent to Broadcast.

func New

func New() *Topic

New creates a new topic. Messages can be broadcast on this topic, and registered consumers are guaranteed to either receive them, or see a channel close.

func (*Topic) Register

func (t *Topic) Register(ch chan<- interface{})

Register starts receiving messages on the given channel. If a channel close is seen, either the topic has been shut down, or the consumer was too slow, and should re-register.

func (*Topic) Unregister

func (t *Topic) Unregister(ch chan<- interface{})

Unregister stops receiving messages on this channel.

Jump to

Keyboard shortcuts

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