dispatcher

package
v3.0.9+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2017 License: MIT Imports: 6 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatcher

type Dispatcher interface {
	Start()
	Stop()
	Send(notification ...Notification)
	Subscribers() []Subscriber
	Registrar
}

Dispatcher forwards a new notification onto subscribers.

func NewDispatcher

func NewDispatcher(delay time.Duration, heartbeatPeriod time.Duration, history History) Dispatcher

NewDispatcher creates and returns a new dispatcher

type History

type History interface {
	Push(notification Notification)
	Notifications() []Notification
}

History contains the last x notifications pushed out to subscribers.

func NewHistory

func NewHistory(size int) History

NewHistory creates a new history type

type Notification

type Notification struct {
	APIURL           string `json:"apiUrl"`
	ID               string `json:"id"`
	Type             string `json:"type"`
	PublishReference string `json:"publishReference,omitempty"`
	LastModified     string `json:"lastModified,omitempty"`
	NotificationDate string `json:"notificationDate,omitempty"`
}

Notification model

type Registrar

type Registrar interface {
	Register(subscriber Subscriber)
	Close(subscriber Subscriber)
}

Registrar (aka Registrator :smirk:) is the interface for a component that manages subscriber registration

type Subscriber

type Subscriber interface {
	NotificationChannel() chan string

	Address() string
	Since() time.Time
	// contains filtered or unexported methods
}

Subscriber represents the interface of a generic subscriber to a push stream

func NewMonitorSubscriber

func NewMonitorSubscriber(address string) Subscriber

NewMonitorSubscriber returns a new instance of a Monitor subscriber

func NewStandardSubscriber

func NewStandardSubscriber(address string) Subscriber

NewStandardSubscriber returns a new instance of a standard subscriber

type SubscriberPayload

type SubscriberPayload struct {
	Address            string `json:"address"`
	Since              string `json:"since"`
	ConnectionDuration string `json:"connectionDuration"`
	Type               string `json:"type"`
}

SubscriberPayload is the JSON representation of a generic subscriber

Jump to

Keyboard shortcuts

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