Documentation
¶
Overview ¶
Package webhook delivers normalized HTTP notifications when Sablier-managed instances change state. It acts as an abstract, provider-agnostic event bridge: regardless of whether the underlying runtime is Docker, Kubernetes, Docker Swarm, Podman, or Proxmox LXC, every consumer receives the same JSON payload structure.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher watches the provider event stream and fires HTTP POST requests to every configured endpoint. It is intentionally stateless: each Watch call subscribes independently and stops when the context is cancelled.
func NewDispatcher ¶
func NewDispatcher(endpoints []config.WebhookEndpoint, logger *slog.Logger) *Dispatcher
NewDispatcher creates a Dispatcher for the given endpoints.
func (*Dispatcher) Validate ¶
func (d *Dispatcher) Validate() error
Validate returns an error if any endpoint in d is misconfigured.
func (*Dispatcher) Watch ¶
func (d *Dispatcher) Watch(ctx context.Context, stream sablier.InstanceEventStream)
Watch consumes events from stream and delivers webhooks for "started" and "stopped" transitions. It returns when ctx is cancelled, the event channel is closed, or a terminal error is received from the stream.
Watch waits for all in-flight HTTP deliveries to complete before returning, so the caller can rely on no goroutines escaping after Watch exits.
Call Watch in a dedicated goroutine.
type InstancePayload ¶
type InstancePayload struct {
// Name is the container / service / workload name as known to Sablier.
Name string `json:"name"`
}
InstancePayload contains the provider-agnostic fields for an instance.
type Payload ¶
type Payload struct {
// Event is the normalized event type: "started" or "stopped".
Event string `json:"event"`
// Instance holds provider-agnostic instance identifiers.
Instance InstancePayload `json:"instance"`
// Timestamp is the UTC time at which the event was processed by Sablier.
Timestamp time.Time `json:"timestamp"`
}
Payload is the normalized JSON body posted to every webhook endpoint. The same structure is used regardless of the underlying provider.