event

package
v0.0.0-...-9ac8f15 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PublishAndSubscribe

func PublishAndSubscribe[T any](ev Event, p EventPublisher, s EventSubscriber) (chan (T), error)

func PublishAndSubscribeFirst

func PublishAndSubscribeFirst[T any](ev Event, p EventPublisher, s EventSubscriber) (T, error)

Publishes an event in a channel using [p], subscribes it's first value using [s], and closes before finishing.

Types

type BaseEvent

type BaseEvent struct {
	Event
	// contains filtered or unexported fields
}

Projects an abstract class that implements the Event Interface.

func (BaseEvent) ID

func (e BaseEvent) ID() string

type BaseEventOutput

type BaseEventOutput struct {
	EventOutput
	// contains filtered or unexported fields
}

func (BaseEventOutput) Error

func (o BaseEventOutput) Error() error

func (BaseEventOutput) Origin

func (o BaseEventOutput) Origin() Event

type CloseSubscription

type CloseSubscription func()

type DisconnectNodeEvent

type DisconnectNodeEvent struct {
	Event
	NodeID string
}

func NewDisconnectNodeEvent

func NewDisconnectNodeEvent(
	nodeID string,
) DisconnectNodeEvent

type DisconnectNodeEventOutput

type DisconnectNodeEventOutput struct {
	EventOutput
}

func NewDisconnectNodeEventOutput

func NewDisconnectNodeEventOutput(
	origin Event,
	err error,
) DisconnectNodeEventOutput

type Event

type Event interface {
	ID() string
}

An event is a message that is published under a channel, which one or more clients can subscribe to.

func NewBaseEvent

func NewBaseEvent(
	id string,
) Event

type EventOutput

type EventOutput interface {
	Origin() Event
	Error() error
}

Represents the output of an event.

func NewBaseEventOutput

func NewBaseEventOutput(
	origin Event,
	err error,
) EventOutput

type EventPublisher

type EventPublisher interface {
	EventStream
	Publish(Event) error
}

An interface for marking clients that can publish events to a channel.

type EventStream

type EventStream interface {
	// If any, returns the public key used by publishers to authenticate
	// events.
	PublicKey() ([]byte, error)
	// Returns the address that the event stream is open on.
	Address() models.Address
}

Represents metadata of an event stream.

type EventSubscriber

type EventSubscriber interface {
	EventStream
	Subscribe(Event) (chan (EventOutput), CloseSubscription)
}

An interface for marking clients that can subscribe the output of events from a channel.

type KillNodeProcessEvent

type KillNodeProcessEvent struct {
	Event
	NodeID string
	PID    int32
}

func NewKillNodeProcessEvent

func NewKillNodeProcessEvent(
	nodeID string,
	pid int32,
) KillNodeProcessEvent

type KillNodeProcessEventOutput

type KillNodeProcessEventOutput struct {
	EventOutput
}

func NewKillNodeProcessEventOutput

func NewKillNodeProcessEventOutput(
	origin Event,
	err error,
) KillNodeProcessEventOutput

type NodeSpeedtestEventOutput

type NodeSpeedtestEventOutput struct {
	EventOutput
	Speedtest models.Speedtest
}

func NewNodeSpeedtestEventOutput

func NewNodeSpeedtestEventOutput(
	origin Event,
	speedtest models.Speedtest,
	err error,
) NodeSpeedtestEventOutput

type QueryNodeConnectionsEvent

type QueryNodeConnectionsEvent struct {
	Event
	NodeID string
}

func NewQueryNodeConnectionsEvent

func NewQueryNodeConnectionsEvent(
	nodeID string,
) QueryNodeConnectionsEvent

type QueryNodeConnectionsEventOutput

type QueryNodeConnectionsEventOutput struct {
	EventOutput
	Connections []models.Connection
}

func NewQueryNodeConnectionsEventOutput

func NewQueryNodeConnectionsEventOutput(
	origin Event,
	connections []models.Connection,
	err error,
) QueryNodeConnectionsEventOutput

type QueryNodePackagesEvent

type QueryNodePackagesEvent struct {
	Event
	NodeID string
}

func NewQueryNodePackagesEvent

func NewQueryNodePackagesEvent(
	nodeID string,
) QueryNodePackagesEvent

type QueryNodePackagesEventOutput

type QueryNodePackagesEventOutput struct {
	EventOutput
	Packages []models.Package
}

func NewQueryNodePackagesEventOutput

func NewQueryNodePackagesEventOutput(
	origin Event,
	packages []models.Package,
	err error,
) QueryNodePackagesEventOutput

type QueryNodeProcessesEvent

type QueryNodeProcessesEvent struct {
	Event
	NodeID string
}

func NewQueryNodeProcessesEvent

func NewQueryNodeProcessesEvent(
	nodeID string,
) QueryNodeProcessesEvent

type QueryNodeProcessesEventOutput

type QueryNodeProcessesEventOutput struct {
	EventOutput
	Processes []models.Process
}

func NewQueryNodeProcessesEventOutput

func NewQueryNodeProcessesEventOutput(
	origin Event,
	processes []models.Process,
	err error,
) QueryNodeProcessesEventOutput

type StartNodeSpeedtestEvent

type StartNodeSpeedtestEvent struct {
	Event
	NodeID string
}

func NewStartNodeSpeedtestEvent

func NewStartNodeSpeedtestEvent(
	nodeID string,
) StartNodeSpeedtestEvent

type ZeroMQEventPubSub

type ZeroMQEventPubSub struct {
	*mq.Socket
}

func NewZeroMQEventPubSub

func NewZeroMQEventPubSub(
	socket *mq.Socket,
) ZeroMQEventPubSub

func (ZeroMQEventPubSub) Address

func (p ZeroMQEventPubSub) Address() models.Address

func (ZeroMQEventPubSub) PublicKey

func (p ZeroMQEventPubSub) PublicKey() ([]byte, error)

func (ZeroMQEventPubSub) Publish

func (p ZeroMQEventPubSub) Publish(e Event) error

func (ZeroMQEventPubSub) Subscribe

func (p ZeroMQEventPubSub) Subscribe(e Event) (chan (EventOutput), CloseSubscription)

Jump to

Keyboard shortcuts

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