Documentation ¶
Index ¶
- Constants
- func NewEventHandler() logrus.Hook
- type DevIncusListener
- type DevIncusServer
- type EventHandler
- type EventListenerConnection
- type EventSource
- type Handler
- type InjectFunc
- type InternalListener
- type Listener
- type NotifyFunc
- type Server
- func (s *Server) AddListener(projectName string, allProjects bool, ...) (*Listener, error)
- func (s *Server) Inject(event api.Event, eventSource EventSource)
- func (s *Server) Send(projectName string, eventType string, eventMessage any) error
- func (s *Server) SendLifecycle(projectName string, event api.EventLifecycle)
- func (s *Server) SetLocalLocation(location string)
Constants ¶
const EventSourceLocal = 0
EventSourceLocal indicates the event was generated locally.
const EventSourcePull = 1
EventSourcePull indicates the event was received from an outbound event listener stream.
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 ¶
NewEventHandler creates and returns a new event handler.
Types ¶
type DevIncusListener ¶
type DevIncusListener struct {
// contains filtered or unexported fields
}
DevIncusListener describes a devIncus event listener.
type DevIncusServer ¶
type DevIncusServer struct {
// contains filtered or unexported fields
}
DevIncusServer represents an instance of an devIncus event server.
func NewDevIncusServer ¶
func NewDevIncusServer(debug bool, verbose bool) *DevIncusServer
NewDevIncusServer returns a new devIncus event server.
func (*DevIncusServer) AddListener ¶
func (s *DevIncusServer) AddListener(instanceID int, connection EventListenerConnection, messageTypes []string) (*DevIncusListener, error)
AddListener creates and returns a new event listener.
type EventHandler ¶
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 Handler ¶
type Handler struct { }
Handler describes an event handler.
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.
type NotifyFunc ¶
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) SendLifecycle ¶
func (s *Server) SendLifecycle(projectName string, event api.EventLifecycle)
SendLifecycle broadcasts a lifecycle event.
func (*Server) SetLocalLocation ¶
SetLocalLocation sets the local location of this member. This value will be added to the Location event field if not populated from another member.