events

package
v2.10.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const EVENT_CHANNEL_QUEUE_SIZE = 100
View Source
const NET_EVENT_FEED_CHANNEL = "net-feed"

a non-fanout channel, where events can be missed

View Source
const NET_ORDERED_CHANNEL = "net-ordered"

net-ordered is a fanout channel,

Variables

This section is empty.

Functions

func BroadcastEvent

func BroadcastEvent(data interface{}) (dropped bool, err error)

This submits an event to every channel, which means every subscriber for every channel name will get the events

func GetDummyEventChannel

func GetDummyEventChannel() (ret chan *MaestroEvent)

GetDummyEventChannel just returns a chan *MaestroEvent, which will never have any events. Useful for select{} statements where the subscription is not yet valid.

func MakeEventChannel

func MakeEventChannel(id string, fanout bool, persistent bool) (ok bool, finalId string, err error)

Make a new channel. If 'id' is an empty string then a random name for the channel is made. If 'fanout' is true, then each subscriber will get their own buffered channel. If 'fanout' is false, if a subscriber's go chan will block then it will miss the event.

func New_eventFIFO

func New_eventFIFO(maxsize uint32) (ret *eventFIFO)

func New_subHttpHandlerFIFO

func New_subHttpHandlerFIFO(maxsize uint32) (ret *subHttpHandlerFIFO)

func OnEventManagerReady

func OnEventManagerReady(cb EventManagerReadyCB)

func SubmitEvent

func SubmitEvent(channelNames []string, data interface{}) (dropped bool, err error)

Submit an event to one or more channels

Types

type DeferredResponder

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

DeferredResponder is anything which might respond later must have a golang chan

func (*DeferredResponder) AssignCloseCallback

func (responder *DeferredResponder) AssignCloseCallback(cb ResponderSubscriptionClosedCallback) (err error)

func (*DeferredResponder) AssignHttpCallback

func (responder *DeferredResponder) AssignHttpCallback(cb EventCallback, w http.ResponseWriter, r *http.Request, ps httprouter.Params) (err error)

type DeferredResponderHandlerChalk

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

func (*DeferredResponderHandlerChalk) ServeHTTP

ServeHTTP implements the http.Handler interface, so the DeferredResponder can itself be the http.Handler for a path / route on the server

type DeferredResponseManager

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

func NewDeferredResponseManager

func NewDeferredResponseManager() (ret *DeferredResponseManager)

func (*DeferredResponseManager) AddEventSubscription

func (manager *DeferredResponseManager) AddEventSubscription(sub EventSubscription) (id string, responder *DeferredResponder, err error)

AddEventSubscription adds a new EventSubscription object, along with a callback which should be called when

func (*DeferredResponseManager) GetResponder

func (manager *DeferredResponseManager) GetResponder(id string) (responder *DeferredResponder, ok bool)

func (*DeferredResponseManager) MakeSubscriptionHttpHandler

func (mymanager *DeferredResponseManager) MakeSubscriptionHttpHandler(pathid string, mypreHandler DeferredResponsePreHandler, myerrorhandler HttpHandler, mainhandler HttpHandler, timeout time.Duration) (ret http.Handler)

MakeSubscriptionHttpHandler returns a http.Handler which will send out events based on the subscrition ID which connects to it. The DeferredResponsePreHandler will determine the subscription ID. This function should not block. The mainhandler is optional, and may be nil. If nil, then each Data element of every event will be JSON encoded as an array and sent when available.

func (*DeferredResponseManager) MakeSubscriptionHttprouterHandler

func (mymanager *DeferredResponseManager) MakeSubscriptionHttprouterHandler(pathid string, mypreHandler DeferredResponsePreHandler3, myerrorhandler HttpHandler, mainhandler HttpHandler, timeout time.Duration) (ret httprouter.Handle)

func (*DeferredResponseManager) RemoveSubscriptionById

func (manager *DeferredResponseManager) RemoveSubscriptionById(id string)

func (*DeferredResponseManager) Start

func (manager *DeferredResponseManager) Start()

func (*DeferredResponseManager) Stop

func (manager *DeferredResponseManager) Stop()

type DeferredResponsePreHandler

type DeferredResponsePreHandler func(http.ResponseWriter, *http.Request) (error, string)

DeferredResponsePreHandler callback is called by DeferredResponseManager when acting as an http.Handler. The function should return the subscription id, or an error if the subscription id cannot be determined

type DeferredResponsePreHandler3

type DeferredResponsePreHandler3 func(http.ResponseWriter, *http.Request, httprouter.Params) (error, string)

DeferredResponsePreHandler3 callback is called by DeferredResponseManager when acting as an httprouter router handler. The function should return the subscription id, or an error if the subscription id cannot be determined

type EventCallback

type EventCallback func(dat *ResponderData, id string, events []*MaestroEvent) //(stop bool, remove bool)

EventCallback is the callback definition to implements when you want to send / process events when they are ready asynchronously via a callback. Return remove at true, to remove the Subscription and stop being called. Return stop as true if you want a pause in the callback being called

type EventHandler

type EventHandler interface {
	// a simple function which is called when new Events
	// are available on 'channel' eventChannel
	HandleEventNotify(channel string)

	// called when a channel is dropping events
	// May do something with the events, or may just
	// ignore them
	HandleEventOverflow(channel string, events []*MaestroEvent)
}

used??

type EventManagerReadyCB

type EventManagerReadyCB func() error

type EventSubscription

type EventSubscription interface {
	GetChannel() (bool, chan *MaestroEvent)
	// call when the channel is not being waiting on
	ReleaseChannel()
	// close the subscription entirely
	Close()
	GetID() string
	IsClosed() bool
}

func GetSubscription

func GetSubscription(channelname string, subscriptionid string) (ok bool, ret EventSubscription)

func SubscribeToChannel

func SubscribeToChannel(name string, timeout int64) (ret EventSubscription, err error)

return back a golang chan, which will be a channel which is subscribed to a specific Event Channel

type HttpHandler

type HttpHandler func(http.ResponseWriter, *http.Request)

type HttpHandler3

type HttpHandler3 func(http.ResponseWriter, *http.Request, httprouter.Params)

type MaestroEvent

type MaestroEvent struct {

	// some data, usually JSON encodable
	Data interface{} `json:"data"`
	// contains filtered or unexported fields
}

func (*MaestroEvent) GetEnqueTime

func (ev *MaestroEvent) GetEnqueTime() (ret int64)

type MaestroEventBaton

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

func PullEvents

func PullEvents(name string, max uint32) (err error, baton *MaestroEventBaton)

func (*MaestroEventBaton) Close

func (this *MaestroEventBaton) Close() (err error)

func (*MaestroEventBaton) Events

func (this *MaestroEventBaton) Events() []*MaestroEvent

type MaestroEventError

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

func (*MaestroEventError) Error

func (this *MaestroEventError) Error() string

type ResponderData

type ResponderData struct {
	Writer  http.ResponseWriter
	Request *http.Request
	Params  httprouter.Params
}

type ResponderSubscriptionClosedCallback

type ResponderSubscriptionClosedCallback func(dat *ResponderData, id string)

ResponderSubscriptionClosedCallback is called when the DeferredResponseManager can no longer access the EventSubscription b/c it was closed

Jump to

Keyboard shortcuts

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