Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StartLongpollManager ¶
func StartLongpollManager() (chan Event, func(w http.ResponseWriter, r *http.Request))
Types ¶
type ClientSubPair ¶
type ClientSubPair struct { ClientUUID uuid.UUID SubscriptionCategory string }
type ClientSubscription ¶
type ClientSubscription struct { ClientSubPair // used to ensure no events skipped between long polls LastEventTime time.Time // we channel arrays of events since we need to send everything a client // cares about in a single channel send. This makes channel receives a // one shot deal. Events chan []Event }
func NewClientSubscription ¶
func NewClientSubscription(subscriptionCategory string, lastEventTime time.Time) (*ClientSubscription, error)
type EventBuffer ¶
type EventBuffer struct { // Doubly linked list of events where new events are added to the back/tail // and old events are removed from the front/root // NOTE: this is efficient for front/back operations since it is // implemented as a ring with root.prev being the tail // SEE: https://golang.org/src/container/list/list.go *list.List MaxBufferSize int }
func (*EventBuffer) GetEventsSince ¶
func (eb *EventBuffer) GetEventsSince(since time.Time) ([]Event, error)
func (*EventBuffer) QueueEvent ¶
func (eb *EventBuffer) QueueEvent(event *Event) error
type EventResponse ¶
type EventResponse struct {
Events *[]Event `json:"events"`
}
type SubscriptionManager ¶
type SubscriptionManager struct { ClientSubscriptions chan ClientSubscription ClientTimeouts <-chan ClientSubPair Events <-chan Event // Contains all client sub channels grouped first by sub id then by // client uuid ClientSubChannels map[string]map[uuid.UUID]chan<- []Event SubEventBuffer map[string]EventBuffer // TODO: ptr to EventBuffer instead of actual value? // channel to inform manager to stop running Quit <-chan bool // How big the buffers are (1-n) before events are discareded FIFO // TODO: enforce sane range 1-n where n isn't batshit crazy MaxEventBufferSize int }
TODO: make types/members private where ever it makes sense
func (*SubscriptionManager) Run ¶
func (sm *SubscriptionManager) Run() error
Click to show internal directories.
Click to hide internal directories.