events

package
v0.0.0-...-11c8b56 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2018 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package events handles sending notifications to users and websockets when system events happen. Such as firing webhooks on workflow transitions.

Index

Constants

This section is empty.

Variables

View Source
var Stop = make(chan int)

Stop is a global channel used to stop the running event managers

Functions

func AddWs

func AddWs(w http.ResponseWriter, r *http.Request, h http.Header)

AddWs calls the method of the same name on the global WSManager

func FireEvent

func FireEvent(ev event.Event)

FireEvent calls the method of the same name on the global EventManager

func RegisterListener

func RegisterListener(ev chan event.Event)

RegisterListener calls the method of the same name on the global EventManager

func Run

func Run()

Run starts the global event manager, should be called in a go routine normally

Types

type EventManager

type EventManager struct {
	Listeners []chan event.Event
}

EventManager manages registered event listeners and dispatching those events

func (EventManager) FireEvent

func (em EventManager) FireEvent(e event.Event)

FireEvent calls the method of the same name on the global EventManager

func (EventManager) RegisterListener

func (em EventManager) RegisterListener(ev chan event.Event)

RegisterListener adds a listener to the EventManager

type ManagedWebsocket

type ManagedWebsocket struct {
	Socket *websocket.Conn
}

ManagedWebsocket wraps a websocket connection and should be managed inside of a single go routine. Websockets are not safe for Concurrent reads and writes and so the ManagedWebsocket is used to guarantee that only one go routine is reading or writing at any given time.

type WSManager

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

WSManager is used to send events to listening websockets

func (*WSManager) AddWs

AddWs will upgrade the given http connection to a websocket and register it with the Websocket Manager

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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