mon

package
v0.28.3 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

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