Documentation ¶
Index ¶
- func EmitEvent(event *Event)
- func Emitter() chan *Event
- func HttpPost(url string, data any) error
- func Must(err error)
- func ReadCsvEvents(fn string, emitter chan *Event) error
- func ReadJsonEvents(fn string, emitter chan *Event) error
- type Event
- type EventFactory
- func (f EventFactory) MakeCall(symbol string, data Payload) *Event
- func (f EventFactory) MakeEvent(kind EventType, symbol string, data Payload) *Event
- func (f EventFactory) MakeSignal(symbol string, data Payload) *Event
- func (f EventFactory) MakeState(symbol string, data Payload) *Event
- func (f EventFactory) Sanitize(event *Event) *Event
- type EventScript
- type EventSender
- type EventType
- type Payload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadCsvEvents ¶
ReadCsvEvents reads events from a csv file and sends them to the emitter channel.
func ReadJsonEvents ¶
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