api

package
v0.0.0-...-ab3ee4f Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const EndSession = "SESSION_END"
View Source
const StartSession = "SESSION_START"
View Source
const TypeEvent = "EVENT"
View Source
const TypeSession = "SESSION"

Variables

This section is empty.

Functions

func GetSessionEvents

func GetSessionEvents(reader SessionReader) http.HandlerFunc

GetSessionEvents gets a session and all it's events over REST

func SSEHandler

func SSEHandler(b *broker.EventBus) http.HandlerFunc

SSEHandler returns a http handler that does Server-Sent-Events

func SetupListenPostgreSQL

func SetupListenPostgreSQL(messages chan []byte, eventName string)

SetupListenPostgreSQL setups a event listener for all events in a PostgreSQL database Note: this requires setting up a LISTEN/NOTIFY proc in the database before events are receivable

func WebsocketHandler

func WebsocketHandler(wr EventWriter) http.HandlerFunc

WebsocketHandler handles incoming websocket event streams

Types

type ClientError

type ClientError struct {
	Error string `json:"error"`
}

ClientError is an error message sent to client when request is incorrect

type Event

type Event struct {
	Type      string `json:"type"`
	Timestamp int64  `json:"timestamp"`
	Name      string `json:"name"`
}

Event is a streamed event

type EventService

type EventService struct {
	SessionEventHandler http.HandlerFunc
	WebsocketHandler    http.HandlerFunc
	EventTypes          EventTypes
	EventBus            broker.EventBus
	DatabaseBus         broker.EventBus
	SSEHandler          http.HandlerFunc
}

EventService is a service to take incoming http events and write them to some output dest

func NewEventService

func NewEventService() (*EventService, error)

NewEventService creates the EventService API

type EventTypes

type EventTypes map[string]int

Event types are all the allowable/known event types from the normalized data store

type EventWriter

type EventWriter interface {
	Write(msg SessionEvent, sessionID string) error
	Init() error
}

EventWriter is an interface that implements writing Events to a destination

type PostgreSQLReader

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

PostgreSQLReader implements SessionReader

func (*PostgreSQLReader) Init

func (p *PostgreSQLReader) Init() error

Init is a DB connection initialization

func (*PostgreSQLReader) SessionEvents

func (p *PostgreSQLReader) SessionEvents(sessionID string) (*SessionEventsResponse, error)

SessionEvents retrieves a Session and all of it's set of events

type PostgreSQLWriter

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

PostgreSQLWriter implements EventWriter by writing to a PostGreSQL database

func (*PostgreSQLWriter) Init

func (p *PostgreSQLWriter) Init() error

Init is a DB connection initialization

func (*PostgreSQLWriter) Write

func (p *PostgreSQLWriter) Write(msg SessionEvent, sessionID string) error

Write inserts session events to a PostgreSQL database

type SessionEvent

type SessionEvent struct {
	Timestamp int    `json:"timestamp"`
	Type      string `json:"type"`
	SessionID string `json:"session_id"`
	Name      string `json:"name"`
}

TODO types for start/stop to be able to do type switches instead of sharing this type Event is an incoming streamed event

type SessionEventsResponse

type SessionEventsResponse struct {
	Type     string  `json:"type"`
	Start    int64   `json:"start"`
	End      int64   `json:"end"`
	Children []Event `json:"children"`
}

SessionEventsResponse request response for a Sessions's events

type SessionReader

type SessionReader interface {
	SessionEvents(sessionID string) (*SessionEventsResponse, error)
	Init() error
}

SessionReader retrieves a session and all related events

type StdOutReader

type StdOutReader struct{}

StdOutReader implements SessionReader interface

func (StdOutReader) Init

func (StdOutReader) Init() error

func (StdOutReader) SessionEvents

func (StdOutReader) SessionEvents(sessionID string) (*SessionEventsResponse, error)

type StdOutWriter

type StdOutWriter struct{}

StdOutWriter implements events.EventWriter and writes to stdout

func (*StdOutWriter) Init

func (s *StdOutWriter) Init() error

func (*StdOutWriter) Write

func (s *StdOutWriter) Write(msg SessionEvent, sessionID string) error

Jump to

Keyboard shortcuts

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