webhook

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDispatcherClosed = errors.New("webhook dispatcher closed")
	ErrQueueFull        = errors.New("webhook queue full")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	URL    string
	Secret string
}

Config holds webhook dispatch configuration.

type Dispatcher

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

Dispatcher sends webhook events asynchronously. When OutboxDir is configured, Enqueue only succeeds after the signed delivery record is durably written.

func NewDispatcher

func NewDispatcher(options Options, logger *zap.Logger) *Dispatcher

NewDispatcher creates a new dispatcher.

func (*Dispatcher) Enqueue

func (d *Dispatcher) Enqueue(event Event) (string, error)

Enqueue sends an event to the dispatcher queue and returns its event ID.

func (*Dispatcher) Identity

func (d *Dispatcher) Identity() (string, string)

Identity returns the current identity context.

func (*Dispatcher) SetConfig

func (d *Dispatcher) SetConfig(url, secret string)

SetConfig updates the webhook target configuration.

func (*Dispatcher) SetIdentity

func (d *Dispatcher) SetIdentity(sandboxID, teamID string)

SetIdentity sets the sandbox and team identifiers.

func (*Dispatcher) Shutdown

func (d *Dispatcher) Shutdown(ctx context.Context) error

Shutdown drains the queue and waits for the worker to finish.

type Event

type Event struct {
	EventID   string    `json:"event_id"`
	EventType EventType `json:"event_type"`
	Timestamp time.Time `json:"timestamp"`
	SandboxID string    `json:"sandbox_id"`
	TeamID    string    `json:"team_id"`
	Payload   any       `json:"payload"`
}

Event represents a webhook event payload.

type EventType

type EventType string

EventType defines the webhook event type.

const (
	// Sandbox events
	EventTypeSandboxReady   EventType = "sandbox.ready"
	EventTypeSandboxKilled  EventType = "sandbox.killed"
	EventTypeSandboxPaused  EventType = "sandbox.paused"
	EventTypeSandboxResumed EventType = "sandbox.resumed"

	// Process events
	EventTypeProcessStarted EventType = "process.started"
	EventTypeProcessExited  EventType = "process.exited"
	EventTypeProcessCrashed EventType = "process.crashed"

	// File system events
	EventTypeFileModified EventType = "file.modified"

	// Agent events
	EventTypeAgentEvent EventType = "agent.event"
)

type Options

type Options struct {
	QueueSize      int
	MaxRetries     int
	BaseBackoff    time.Duration
	RequestTimeout time.Duration
	OutboxDir      string
}

Options controls dispatcher behavior.

Jump to

Keyboard shortcuts

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