bus

package
v0.0.0-...-2209333 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	From int
	To   int
}

type Connections

type Connections []Connection

type EditorType

type EditorType string
const (
	Neovim EditorType = "neovim"
	Entry  EditorType = "entry"
)

type Event

type Event struct {
	Type EventType `json:"type"`
	Data any       `json:"data"`
}

type EventBus

type EventBus interface {
	Bind(etype EventType, cb any)
	AwaitBind(etype EventType, cb any) bool
	Publish(e Event)
	AwaitPublish(e Event) bool
	Unbind(etype EventType, cb any)
	AwaitUnbind(etype EventType, cb any) bool
	AwaitEvent(ctx context.Context, etype EventType)
}

func NewEventbus

func NewEventbus() EventBus

type EventType

type EventType string
const AwaitEndEvt EventType = "await-end"
const AwaitStartEvt EventType = "await-start"

The await events are used by nodes to signal the GUI that they are waiting for some message to arrive

const ConnectNodesEvt EventType = "connect-nodes"

When nodes get (dis-)connected (usually through the GUI) these events are published

const ContinueNodesEvt EventType = "continue-nodes"
const DebugNodesEvt EventType = "debug-nodes"
const DisconnectNodesEvt EventType = "disconnect-nodes"
const EditorSelectEvt EventType = "editor-select"

The following events are used to communicate the selection of an editor

const NetworkConnectionsEvt EventType = "network-connections"

When the network is resized, this event is published to inform the GUI TODO : Check if this is necessary or if the GUI can keep track itself from the connect/disconnect events. If its necessary as some sort of confirmation, a rule is needed to clear up which events need "confirmation" events and make them easier to identify e.g. by a pre-/postfix.

const NetworkResizeEvt EventType = "network-resize"

When the network is resized, this event is published to inform the GUI TODO : similar to the NetworkConnectionsEvt, this seems to be required for confirmation as some resize inputs are invalid (e.g. negative values). The GUI should just not allow such values, making this event unnecessary.

const NodeCntChangeEvt EventType = "node-count-change"

This event notifies the network of a change in the amount of nodes to be used

const NodeDataChangeEvt EventType = "node-data-change"

When a nodes custom input data changes, this event is published

const NodeOutputEvt EventType = "node-output"

This event may be used by nodes to communicate their logs to the GUI

const OpenEvt EventType = "open"

OpenEvt communicates that a project has been opened

const SentToEvt EventType = "sent-to"

SentToEvt is used by nodes to communicate to the GUI that they have sent data to another node

const StartNodesEvt EventType = "start-nodes"

The following events transfer the nodes from one state to another

const StopNodesEvt EventType = "stop-nodes"

type NetworkResize

type NetworkResize struct {
	Connections
	Cnt int
}

type NodeCnt

type NodeCnt int

type NodeData

type NodeData struct {
	TargetId int
	Data     any
}

type NodeId

type NodeId int

TODO : if we keep this, other structs should use it aswell, e.g. the NodeOutput struct

type NodeOutput

type NodeOutput struct {
	Log    string
	Result any
	NodeId int
}

type SendTask

type SendTask struct {
	From int
	To   int
	Data any
}

type Source

type Source struct {
	Path string // should be structured as returned by uri.Path()
	Type SourceType
}

type SourceType

type SourceType string
const (
	File      SourceType = "file"
	Directory SourceType = "directory"
)

Jump to

Keyboard shortcuts

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