pubsub

package
v0.0.0-...-cc96157 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2015 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	Content   string    `json:"message"`
	Published time.Time `json:"published,omitempty"`
}

type PubSub

type PubSub struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func New

func New() *PubSub

New returns a new PubSub instance with a Nats encoded connection

func (*PubSub) GetMessages

func (ps *PubSub) GetMessages(w http.ResponseWriter, r *http.Request, p httprouter.Params)

GetMessages returns published messages to the subscriber since subscription. GET /:topic_name/:subscriber_name

func (*PubSub) PublishMessage

func (ps *PubSub) PublishMessage(w http.ResponseWriter, r *http.Request, p httprouter.Params)

PublishMessage send a message to all subscribers POST /:topic_name

func (*PubSub) SetupRoutes

func (ps *PubSub) SetupRoutes(router *httprouter.Router) *httprouter.Router

SetupRoutes maps routes to the PubSub's handlers

func (*PubSub) Subscribe

func (ps *PubSub) Subscribe(w http.ResponseWriter, r *http.Request, p httprouter.Params)

Subscribe adds a subscription to a topic. The subscriber will not receive previously published messages for the topic. POST /:topic_name/:subscriber_name

func (*PubSub) Unsubscribe

func (ps *PubSub) Unsubscribe(w http.ResponseWriter, r *http.Request, p httprouter.Params)

Unsubscribe removes a subscription of a topic. DELETE /:topic_name/:subscriber_name

Jump to

Keyboard shortcuts

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