events

package
v0.0.0-...-ff4e629 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const EventSourceLocal = 0

EventSourceLocal indicates the event was generated locally.

View Source
const EventSourcePull = 1

EventSourcePull indicates the event was received from an outbound event listener stream.

View Source
const EventSourcePush = 2

EventSourcePush indicates the event was received from an event listener client connected to us.

Variables

This section is empty.

Functions

func NewEventHandler

func NewEventHandler() logrus.Hook

NewEventHandler creates and returns a new event handler.

Types

type DevLXDListener

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

DevLXDListener describes a devlxd event listener.

func (*DevLXDListener) Close

func (e *DevLXDListener) Close()

Close Disconnects the listener.

func (*DevLXDListener) ID

func (e *DevLXDListener) ID() string

ID returns the listener ID.

func (*DevLXDListener) IsClosed

func (e *DevLXDListener) IsClosed() bool

IsClosed returns true if the listener is closed.

func (*DevLXDListener) Wait

func (e *DevLXDListener) Wait(ctx context.Context)

Wait waits for a message on its active channel or the context is cancelled, then returns.

type DevLXDServer

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

DevLXDServer represents an instance of an devlxd event server.

func NewDevLXDServer

func NewDevLXDServer(debug bool, verbose bool) *DevLXDServer

NewDevLXDServer returns a new devlxd event server.

func (*DevLXDServer) AddListener

func (s *DevLXDServer) AddListener(instanceID int, connection EventListenerConnection, messageTypes []string) (*DevLXDListener, error)

AddListener creates and returns a new event listener.

func (*DevLXDServer) Send

func (s *DevLXDServer) Send(instanceID int, eventType string, eventMessage any) error

Send broadcasts a custom event.

type EventHandler

type EventHandler func(event api.Event)

EventHandler called when the connection receives an event from the client.

type EventListenerConnection

type EventListenerConnection interface {
	Reader(ctx context.Context, recvFunc EventHandler)
	WriteJSON(event any) error
	Close() error
	LocalAddr() net.Addr  // Used for logging
	RemoteAddr() net.Addr // Used for logging
}

EventListenerConnection represents an event listener connection.

func NewSimpleListenerConnection

func NewSimpleListenerConnection(rwc io.ReadWriteCloser) EventListenerConnection

NewSimpleListenerConnection returns a new simple listener connection.

func NewStreamListenerConnection

func NewStreamListenerConnection(connection net.Conn) (EventListenerConnection, error)

NewStreamListenerConnection returns a new http stream listener connection.

func NewWebsocketListenerConnection

func NewWebsocketListenerConnection(connection *websocket.Conn) EventListenerConnection

NewWebsocketListenerConnection returns a new websocket listener connection.

type EventSource

type EventSource uint8

EventSource indicates the source of an event.

type Handler

type Handler struct {
}

Handler describes an event handler.

func (Handler) Fire

func (h Handler) Fire(entry *logrus.Entry) error

Fire sends a new logging event.

func (Handler) Levels

func (h Handler) Levels() []logrus.Level

Levels returns the list of supported log levels.

type InjectFunc

type InjectFunc func(event api.Event, eventSource EventSource)

InjectFunc is used to inject an event received by a listener into the local events dispatcher.

type InternalListener

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

InternalListener represents a internal event listener.

func NewInternalListener

func NewInternalListener(ctx context.Context, server *Server) *InternalListener

NewInternalListener returns an InternalListener.

func (*InternalListener) AddHandler

func (l *InternalListener) AddHandler(name string, handler EventHandler)

AddHandler adds a new event handler.

func (*InternalListener) RemoveHandler

func (l *InternalListener) RemoveHandler(name string)

RemoveHandler removes the event handler with the given name.

type Listener

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

Listener describes an event listener.

func (*Listener) Close

func (e *Listener) Close()

Close Disconnects the listener.

func (*Listener) ID

func (e *Listener) ID() string

ID returns the listener ID.

func (*Listener) IsClosed

func (e *Listener) IsClosed() bool

IsClosed returns true if the listener is closed.

func (*Listener) Wait

func (e *Listener) Wait(ctx context.Context)

Wait waits for a message on its active channel or the context is cancelled, then returns.

type NotifyFunc

type NotifyFunc func(event api.Event)

NotifyFunc is called when an event is dispatched.

type Server

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

Server represents an instance of an event server.

var LoggingServer *Server

LoggingServer controls what server to use for messages coming from the logger.

func NewServer

func NewServer(debug bool, verbose bool, notify NotifyFunc) *Server

NewServer returns a new event server.

func (*Server) AddListener

func (s *Server) AddListener(projectName string, allProjects bool, projectPermissionFunc auth.PermissionChecker, connection EventListenerConnection, messageTypes []string, excludeSources []EventSource, recvFunc EventHandler, excludeLocations []string) (*Listener, error)

AddListener creates and returns a new event listener.

func (*Server) Inject

func (s *Server) Inject(event api.Event, eventSource EventSource)

Inject an event from another member into the local events dispatcher. eventSource is used to indicate where this event was received from.

func (*Server) Send

func (s *Server) Send(projectName string, eventType string, eventMessage any) error

Send broadcasts a custom event.

func (*Server) SendLifecycle

func (s *Server) SendLifecycle(projectName string, event api.EventLifecycle)

SendLifecycle broadcasts a lifecycle event.

func (*Server) SetLocalLocation

func (s *Server) SetLocalLocation(location string)

SetLocalLocation sets the local location of this member. This value will be added to the Location event field if not populated from another member.

Jump to

Keyboard shortcuts

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