notify

package
v0.0.0-...-5d9d701 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 16 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPSender

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

HTTPSender delivers webhook notifications to configured endpoints.

func NewHTTPSender

func NewHTTPSender(endpoints []config.NotifyEndpointConfig) *HTTPSender

NewHTTPSender creates a new HTTP webhook sender.

func (*HTTPSender) Endpoints

func (s *HTTPSender) Endpoints() []config.NotifyEndpointConfig

Endpoints returns a copy of the active webhook policy.

func (*HTTPSender) Send

func (s *HTTPSender) Send(p *NotifyPayload)

Send enqueues a payload for delivery. Non-blocking; drops if queue is full.

func (*HTTPSender) Start

func (s *HTTPSender) Start()

Start begins the worker goroutine that drains the queue.

func (*HTTPSender) Stop

func (s *HTTPSender) Stop()

Stop signals the worker to exit and waits for drain.

func (*HTTPSender) StopWithTimeout

func (s *HTTPSender) StopWithTimeout(timeout time.Duration) bool

StopWithTimeout signals the worker, drains events admitted before the stop, and waits up to timeout. A non-positive timeout waits without a deadline.

func (*HTTPSender) UpdateEndpoints

func (s *HTTPSender) UpdateEndpoints(endpoints []config.NotifyEndpointConfig)

UpdateEndpoints publishes a copied endpoint list for subsequent deliveries.

type Module

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

Module implements HTTP and WebSocket notifications for stream lifecycle events.

func NewModule

func NewModule() *Module

NewModule creates a new notify module.

func (*Module) Close

func (m *Module) Close() error

Close stops the HTTP and WebSocket senders.

func (*Module) Hooks

func (m *Module) Hooks() []core.HookRegistration

Hooks returns async hooks for all lifecycle events at priority 90.

func (*Module) Init

func (m *Module) Init(s *core.Server) error

Init reads config and starts the HTTP and WebSocket senders.

func (*Module) Name

func (m *Module) Name() string

Name returns the module name.

func (*Module) OnReload

func (m *Module) OnReload(s *core.Server) error

OnReload applies webhook endpoint, timeout, secret, retry, and event-filter policy to subsequent deliveries. WebSocket enablement/path changes still require restart because they alter route registration.

type NotifyPayload

type NotifyPayload struct {
	Event      string         `json:"event"`
	StreamKey  string         `json:"stream_key"`
	Protocol   string         `json:"protocol,omitempty"`
	RemoteAddr string         `json:"remote_addr,omitempty"`
	Timestamp  int64          `json:"timestamp"`
	Extra      map[string]any `json:"extra,omitempty"`
}

NotifyPayload is the JSON body sent to webhook endpoints.

func BuildPayload

func BuildPayload(eventName string, ctx *core.EventContext) *NotifyPayload

BuildPayload creates a NotifyPayload from an event name and context.

type WSSender

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

WSSender manages WebSocket notification clients.

func NewWSSender

func NewWSSender() *WSSender

NewWSSender creates a new WebSocket notification sender.

func (*WSSender) ClientCount

func (s *WSSender) ClientCount() int

ClientCount returns the number of connected WebSocket clients.

func (*WSSender) Close

func (s *WSSender) Close()

Close permanently stops client admission and disconnects all clients.

func (*WSSender) Dropped

func (s *WSSender) Dropped() uint64

Dropped returns the number of notification messages rejected by full client queues since the sender was created.

func (*WSSender) HandleWebSocket

func (s *WSSender) HandleWebSocket(w http.ResponseWriter, r *http.Request)

HandleWebSocket upgrades an HTTP connection to a WebSocket notification stream. Query parameter "events" is a comma-separated list of event names to filter. If omitted, all events are sent.

func (*WSSender) Send

func (s *WSSender) Send(p *NotifyPayload)

Send broadcasts a payload to all connected clients whose event filter matches.

Jump to

Keyboard shortcuts

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