ecal

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: MPL-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package ecal contains the main API for the event condition action language (ECAL).

Index

Constants

This section is empty.

Variables

View Source
var EventMapping = map[int]string{

	graph.EventNodeCreated: "db.node.created",

	graph.EventNodeUpdated: "db.node.updated",

	graph.EventNodeDeleted: "db.node.deleted",

	graph.EventEdgeCreated: "db.edge.created",

	graph.EventEdgeUpdated: "db.edge.updated",

	graph.EventEdgeDeleted: "db.edge.deleted",

	graph.EventNodeStore: "db.node.store",

	graph.EventNodeUpdate: "db.node.update",

	graph.EventNodeDelete: "db.node.delete",

	graph.EventEdgeStore: "db.edge.store",

	graph.EventEdgeDelete: "db.edge.delete",
}

EventMapping is a mapping between EliasDB event types to EliasDB specific event kinds in ECAL.

Functions

func AddEliasDBStdlibFunctions

func AddEliasDBStdlibFunctions(gm *graph.Manager)

AddEliasDBStdlibFunctions adds EliasDB related ECAL stdlib functions.

Types

type EventBridge

type EventBridge struct {
	Processor engine.Processor
	Logger    util.Logger
}

EventBridge is a rule for a graph manager to forward all graph events to ECAL.

func (*EventBridge) Handle

func (eb *EventBridge) Handle(gm *graph.Manager, trans graph.Trans, event int, ed ...interface{}) error

Handle handles an event.

func (*EventBridge) Handles

func (eb *EventBridge) Handles() []int

Handles returns a list of events which are handled by this rule.

func (*EventBridge) Name

func (eb *EventBridge) Name() string

Name returns the name of the rule.

type ScriptingInterpreter

type ScriptingInterpreter struct {
	GM          *graph.Manager       // GraphManager for the interpreter
	Interpreter *tool.CLIInterpreter // ECAL Interpreter object

	Dir       string // Root dir for interpreter
	EntryFile string // Entry file for the program
	LogLevel  string // Log level string (Debug, Info, Error)
	LogFile   string // Logfile (blank for stdout)

	RunDebugServer  bool   // Run a debug server
	DebugServerHost string // Debug server host
	DebugServerPort string // Debug server port

	WebsocketConnections *datautil.MapCache
}

ScriptingInterpreter models a ECAL script interpreter instance.

func NewScriptingInterpreter

func NewScriptingInterpreter(scriptFolder string, gm *graph.Manager) *ScriptingInterpreter

NewScriptingInterpreter returns a new ECAL scripting interpreter.

func (*ScriptingInterpreter) DeregisterECALSock

func (si *ScriptingInterpreter) DeregisterECALSock(conn *WebsocketConnection)

DeregisterECALSock removes a registered websocket.

func (*ScriptingInterpreter) HandleECALSockEvent

func (si *ScriptingInterpreter) HandleECALSockEvent(p engine.Processor, m engine.Monitor, e *engine.Event, tid uint64) error

HandleECALSockEvent handles websocket events from the ECAL interpreter (db.web.sock.msg events).

func (*ScriptingInterpreter) RegisterECALSock

func (si *ScriptingInterpreter) RegisterECALSock(conn *WebsocketConnection)

RegisterECALSock registers a websocket which should be connected to ECAL events.

func (*ScriptingInterpreter) Run

func (si *ScriptingInterpreter) Run() error

Run runs the ECAL scripting interpreter.

After this function completes: - EntryScript in config and all related scripts in the interpreter root dir have been executed - ECAL Interpreter object is fully initialized - A debug server might be running which can reload the entry script - ECAL's event processor has been started - GraphManager events are being forwarded to ECAL

type WebsocketConnection

type WebsocketConnection struct {
	CommID string
	Conn   *websocket.Conn
	RMutex *sync.Mutex
	WMutex *sync.Mutex
}

WebsocketConnection models a single websocket connection.

Websocket connections support one concurrent reader and one concurrent writer. See: https://godoc.org/github.com/gorilla/websocket#hdr-Concurrency

func NewWebsocketConnection

func NewWebsocketConnection(commID string, c *websocket.Conn) *WebsocketConnection

NewWebsocketConnection creates a new WebsocketConnection object.

func (*WebsocketConnection) Close

func (wc *WebsocketConnection) Close(msg string)

Close closes the websocket connection.

func (*WebsocketConnection) Init

func (wc *WebsocketConnection) Init()

Init initializes the websocket connection.

func (*WebsocketConnection) ReadData

func (wc *WebsocketConnection) ReadData() (map[string]interface{}, bool, error)

ReadData reads data from the websocket connection.

func (*WebsocketConnection) WriteData

func (wc *WebsocketConnection) WriteData(data map[string]interface{})

WriteData writes data to the websocket.

Directories

Path Synopsis
Package dbfunc contains EliasDB specific functions for the event condition action language (ECAL).
Package dbfunc contains EliasDB specific functions for the event condition action language (ECAL).

Jump to

Keyboard shortcuts

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