event

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2024 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"
	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"
	ENGINE_EMR_TIMEOUT       = "engine-emr-timeout"
	LCO_COLLECT_PANIC        = "lco-collect-panic"
	LCO_RECEIVER_PANIC       = "lco-receiver-panic"
	LCO_PAUSED               = "lco-paused"
	LCO_RUNNING              = "lco-running"
	LCO_METRICS_FAULT        = "lco-metrics-fault"
	MONITOR_CONNECTED        = "connected"
	MONITOR_CONNECTING       = "connecting"
	MONITOR_ERROR            = "monitor-error"
	MONITOR_PANIC            = "monitor-panic"
	MONITOR_STARTED          = "monitor-started"
	MONITOR_STOPPED          = "monitor-stopped"
	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 (
	COLLECTOR_CMR_TIMEOUT = "collector-cmr-timeout"
	COLLECTOR_ERROR       = "collector-error"
	COLLECTOR_PANIC       = "collector-panic"
	COLLECTOR_FAULT       = "collector-fault"
	DROP_METRICS_FENCE    = "drop-metrics-fence"   // behind fence due to collector fault
	DROP_METRICS_FLUSH    = "drop-metrics-flush"   // Engine.collectionChan <- collection{} blocked
	DROP_METRICS_RUNTIME  = "drop-metrics-runtime" // @todo collection.runtime > user-configured timeout
)
View Source
const (
	SINK_INVALID_METRICS = "sink-invalid-metrics" // invalid metrics, drop
	SINK_SERVER_ERROR    = "sink-server-error"    // send ok but remote server returned an error
	SINK_SEND_ERROR      = "sink-send-error"      // e.g. network timeout
)

Sink Events

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 RemoveSubscribers added in v1.2.0

func RemoveSubscribers()

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. The receiver can be set only once, so subsequent calls to this function have no effect.

func Subscribe added in v1.2.0

func Subscribe(r Receiver)

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
	// contains filtered or unexported fields
}

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