event

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package event provides a simple event stream in lieu of standard logging.

Index

Constants

View Source
const (
	BOOT_CONFIG_INVALID   = "boot-config-invalid"
	BOOT_CONFIG_LOADED    = "boot-config-loaded"
	BOOT_CONFIG_LOADING   = "boot-config-loading"
	BOOT_ERROR            = "boot-error"
	BOOT_START            = "boot-start"
	BOOT_SUCCESS          = "boot-success"
	MONITORS_LOADED       = "monitors-loaded"
	MONITORS_LOADING      = "monitors-loading"
	MONITORS_RELOAD_ERROR = "monitors-reload-error"
	MONITORS_STARTED      = "monitors-started"
	MONITORS_STARTING     = "monitors-starting"
	MONITORS_STOPLOSS     = "monitors-stoploss"
	MONITOR_LOADER_PANIC  = "monitor-loader-panic"
	PLANS_LOAD_MONITOR    = "plans-load-monitor"
	PLANS_LOAD_SHARED     = "plans-load-shared"
	SERVER_API_PANIC      = "server-api-panic"
	SERVER_API_ERROR      = "server-api-error"
	SERVER_RUN            = "server-run"
	SERVER_STOPPED        = "server-stopped"
)

Blip events (non-monitor)

View Source
const (
	CHANGE_PLAN              = "change-plan"
	CHANGE_PLAN_ERROR        = "change-plan-error"
	CHANGE_PLAN_SUCCESS      = "change-plan-success"
	COLLECTOR_ERROR          = "collector-error"
	COLLECTOR_PANIC          = "collector-panic"
	DB_RELOAD_PASSWORD_ERROR = "db-reload-password-error"
	ENGINE_COLLECT_ERROR     = "engine-collect-error"
	ENGINE_PREPARE           = "engine-prepare"
	ENGINE_PREPARE_ERROR     = "engine-prepare-error"
	ENGINE_PREPARE_SUCCESS   = "engine-prepare-success"
	LPC_BLOCKED              = "lpc-blocked"
	LPC_PANIC                = "lpc-panic"
	LPC_PAUSED               = "lpc-paused"
	LPC_RUNNING              = "lpc-running"
	MONITOR_CONNECTED        = "connected"
	MONITOR_CONNECTING       = "connecting"
	MONITOR_ERROR            = "monitor-error"
	MONITOR_PANIC            = "monitor-panic"
	MONITOR_STARTED          = "monitor-started"
	MONITOR_STOPPED          = "monitor-stopped"
	SINK_SEND_ERROR          = "sink-send-error"
	STATE_CHANGE_ABORT       = "state-change-abort"
	STATE_CHANGE_BEGIN       = "state-change-begin"
	STATE_CHANGE_END         = "state-change-end"
	REPL_SOURCE_CHANGE       = "repl-soruce-change"
)

Monitor events

View Source
const (
	SINK_ERROR = "sink-error"
)

Variables

This section is empty.

Functions

func Errorf

func Errorf(eventName string, msg string, args ...interface{})

Errorf sends an event flagged as an error with a formatted message.

func Send

func Send(eventName string)

Send sends an event with no additional message. This is a convenience function for Sendf. Non-monitor parts of Blip use this function.

func Sendf

func Sendf(eventName string, msg string, args ...interface{})

Sendf sends an event and formatted message. Non-monitor parts of Blip use this function.

func SetReceiver

func SetReceiver(r Receiver)

SetReceiver sets the receiver used by Blip to handle events. The default receiver is Log. To override the default, call this function to set a new receiver before calling Server.Boot.

Types

type Event

type Event struct {
	Ts        time.Time
	Event     string
	MonitorId string
	Message   string
	Error     bool
}

Event is something that happened in Blip. Events replace traditional logging. All parts of Blip send detailed events about what's happening.

type Log

type Log struct {
	All bool
}

Log is the default Receiver that uses the Go built-in log package to print certain events to STDOUT and error events to STDERR. Call SetReceiver to override this default.

func (Log) Recv

func (s Log) Recv(e Event)

type MonitorReceiver

type MonitorReceiver struct {
	MonitorId string
}

MonitorReceiver is a Receiver bound to a single monitor. Monitors use this type to send events with the monitor ID.

func (MonitorReceiver) Errorf

func (s MonitorReceiver) Errorf(eventName string, msg string, args ...interface{})

func (MonitorReceiver) Recv

func (s MonitorReceiver) Recv(e Event)

func (MonitorReceiver) Send

func (s MonitorReceiver) Send(eventName string)

Send sends an event with no additional message from the monitor. This is a convenience function for Sendf.

func (MonitorReceiver) Sendf

func (s MonitorReceiver) Sendf(eventName string, msg string, args ...interface{})

Sendf sends an event and formatted message from the monitor.

type Receiver

type Receiver interface {
	// Recv receives one event asynchronously. It must not block.
	// A specific implementation determines what is done with the event: logged,
	// sent to Slack, emitted to a pseudo metric, and so on.
	Recv(Event)
}

A Receiver sends events to a destination. Use Tee to send events to multiple destinations. Implementations must be non-blocking; callers expect this.

type Tee

type Tee struct {
	Receiver Receiver
	Out      Receiver
}

Tee connects multiple Receiver, like the Unix tee command. It implements Receiver. On Tee.Recv, it copies the event to a real receiver: Tee.Receiver. Then it copies the event to Tee.Out, if Out is not nil. To "pipe fit" multiple Tee together, use another Tee for Out.

  event --> Tee.Recv --> Tee.Out.Recv // second
			   |
            +-> Tee.Receiver.Recv // first

func (Tee) Recv

func (t Tee) Recv(e Event)

Jump to

Keyboard shortcuts

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