webhook

package
v1.8.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dispatch

func Dispatch(path string, msg hermod.Message) error

Dispatch sends a message to the channel registered for the given path.

func Register

func Register(path string) chan hermod.Message

Register creates a new channel for a webhook path, superseding any existing registration. The newest registration owns the path: when a workflow moves between workers, the one taking the lease over is the one that should receive.

func Unregister

func Unregister(path string, ch chan hermod.Message)

Unregister releases a path, but only if ch is still the channel registered for it.

The ownership check is what makes a handover safe. Nothing orders the outgoing worker's teardown against the incoming worker's registration, so deleting by path alone let a worker that had already lost the lease close and remove its successor's channel. The successor was then reading from a closed channel that no longer appeared in the registry: the workflow reported itself running and never received another message.

A stale caller now finds its channel is no longer the registered one and leaves the path alone. Its own channel is simply dropped — its reader has already returned through the cancelled context, and nothing else holds it.

Types

type WebhookSource

type WebhookSource struct {
	Path string
	// contains filtered or unexported fields
}

WebhookSource implements the hermod.Source interface for receiving HTTP requests.

func NewWebhookSource

func NewWebhookSource(path string) *WebhookSource

NewWebhookSource creates a new WebhookSource.

func (*WebhookSource) Ack

func (s *WebhookSource) Ack(ctx context.Context, msg hermod.Message) error

Ack is a no-op for webhooks.

func (*WebhookSource) Close

func (s *WebhookSource) Close() error

Close unregisters the source, unless another has already taken the path over.

func (*WebhookSource) Ping

func (s *WebhookSource) Ping(ctx context.Context) error

Ping is a no-op for webhooks.

func (*WebhookSource) Read

func (s *WebhookSource) Read(ctx context.Context) (hermod.Message, error)

Read blocks until a message is received via Dispatch.

Jump to

Keyboard shortcuts

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