Documentation ¶
Overview ¶
Package event provides a simple event stream in lieu of standard logging.
Index ¶
Constants ¶
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)
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
const (
SINK_ERROR = "sink-error"
)
Variables ¶
This section is empty.
Functions ¶
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 ¶
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 ¶
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.
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 ¶
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