mon

package
v0.51.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	MonitorSubject = "mon"
)

Variables

View Source
var Emitter = helper.Hook[Event]{}

Functions

func Must

func Must(err error)

Types

type Event

type Event struct {
	Id        string    `json:"id" yaml:"id" csv:"id"`
	Source    string    `json:"source" yaml:"source" csv:"source"`
	Type      EventType `json:"type" yaml:"type" csv:"type"`
	Timestamp time.Time `json:"timestamp" yaml:"timestamp" csv:"timestamp"`
	Symbol    string    `json:"symbol" yaml:"symbol" csv:"symbol"`
	Data      Payload   `json:"data" yaml:"data" csv:"data"`
}

Event represents an API event.

func ReadCsvEvents

func ReadCsvEvents(fn string) ([]Event, error)

ReadCsvEvents reads events from a csv file and sends them to the emitter channel.

func ReadJsonEvents

func ReadJsonEvents(fn string) ([]Event, error)

ReadJsonEvents reads monitor events from a json stream file

func (*Event) Subject added in v0.45.0

func (e *Event) Subject() string

type EventFactory

type EventFactory struct {
	Source string
}

EventFactory is used to create events. Factory associates device ids and sources with events.

func NewEventFactory

func NewEventFactory(source string) *EventFactory

NewEventFactory creates a new event factory.

func (EventFactory) MakeCall

func (f EventFactory) MakeCall(symbol string, data Payload) *Event

MakeCall creates a call event with the given symbol and params.

func (EventFactory) MakeEvent

func (f EventFactory) MakeEvent(kind EventType, symbol string, data Payload) *Event

MakeEvent creates an event with the given kind, symbol and params.

func (EventFactory) MakeSignal

func (f EventFactory) MakeSignal(symbol string, data Payload) *Event

MakeSignal creates a signal event with the given symbol and params.

func (EventFactory) MakeState

func (f EventFactory) MakeState(symbol string, data Payload) *Event

MakeState creates a state event with the given symbol and props.

func (EventFactory) Sanitize

func (f EventFactory) Sanitize(event *Event) *Event

Sanitize ensures events are valid and fills in missing fields.

type EventScript

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

func NewEventScript

func NewEventScript() *EventScript

func (*EventScript) RunScript

func (s *EventScript) RunScript(script string) ([]Event, error)

func (*EventScript) RunScriptFromFile

func (s *EventScript) RunScriptFromFile(file string) ([]Event, error)

type EventType

type EventType string

EventType is the type of event.

const (
	TypeCall   EventType = "call"
	TypeSignal EventType = "signal"
	TypeState  EventType = "state"
)

func ParseEventType

func ParseEventType(s string) EventType

func (EventType) String

func (e EventType) String() string

type Payload

type Payload map[string]any

Jump to

Keyboard shortcuts

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