mon

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmitEvent

func EmitEvent(event *Event)

EmitEvents writes events to the emitter channel.

func Emitter

func Emitter() chan *Event

Emitter returns the emitter channel.

func HttpPost

func HttpPost(url string, data any) error

func Must

func Must(err error)

func ReadCsvEvents

func ReadCsvEvents(fn string, emitter chan *Event) error

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

func ReadJsonEvents

func ReadJsonEvents(fn string, emitter chan *Event) error

ReadJsonEvents reads events from a json stream file and sends them to the emitter channel.

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.

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(emitter chan *Event) *EventScript

func (*EventScript) RunScript

func (s *EventScript) RunScript(script string) error

func (*EventScript) RunScriptFromFile

func (s *EventScript) RunScriptFromFile(file string) error

type EventSender

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

EventSender is a sender of events. It sends events to the monitor server

func NewEventSender

func NewEventSender(url string) *EventSender

func (*EventSender) SendEvents

func (s *EventSender) SendEvents(emitter chan *Event, sleep time.Duration)

SendEvents sends events to the monitor server. The events are sent as json encoded strings. The events are sent to the monitor server using a http post message

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