event

package
v0.0.0-...-043d1ac Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2017 License: AGPL-3.0-or-later, GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Pub/sub messaging system using mongodb tailable cursor.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Publish

func Publish(db *database.Database, channel string, data interface{}) (
	err error)

func Register

func Register(channel string, event string, callback func(*Event))

func Subscribe

func Subscribe(db *database.Database, channels []string,
	duration time.Duration, onMsg func(*Event) bool) (err error)

Types

type Dispatch

type Dispatch struct {
	Type string `bson:"type" json:"type"`
}

type Event

type Event struct {
	Id        bson.ObjectId `bson:"_id,omitempty" json:"id"`
	Channel   string        `bson:"channel" json:"channel"`
	Timestamp time.Time     `bson:"timestamp" json:"timestamp"`
	Data      interface{}   `bson:"data" json:"data"`
}

type Listener

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

func SubscribeListener

func SubscribeListener(channels []string) (lst *Listener, err error)

func (*Listener) Close

func (l *Listener) Close()

func (*Listener) Listen

func (l *Listener) Listen() chan *Event

Jump to

Keyboard shortcuts

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