workers

package
v1.5.12 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package workers ports the bootnode background workers. It currently provides webhook delivery (the Go equivalent of bootnode/workers/webhook.py): sign a payload with the webhook's HMAC secret, POST it, and return the delivery outcome for the caller to persist.

This is a library, not a daemon. Base does not run arq; delivery is driven by the plugin (synchronously on the event, or from a Base task/scheduler). The dispatch logic — signing, timeout, retry accounting — lives here, decoupled from any queue.

Index

Constants

View Source
const SignatureHeader = "X-Bootnode-Signature"

SignatureHeader is the header carrying the HMAC-SHA256 signature of the body.

Variables

This section is empty.

Functions

func Sign

func Sign(secret string, payload []byte) string

Sign returns the hex-encoded HMAC-SHA256 of payload under secret. Exposed so receivers (and tests) can verify deliveries.

Types

type Delivery

type Delivery struct {
	StatusCode   int
	ResponseBody string
	Success      bool
	Error        string
}

Delivery is the outcome of a single webhook delivery attempt. The plugin persists it to the _bootnode_webhook_deliveries collection.

type Dispatcher

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

Dispatcher delivers signed webhook payloads.

func NewDispatcher

func NewDispatcher(timeout time.Duration) *Dispatcher

NewDispatcher constructs a Dispatcher with the given per-request timeout. A zero timeout defaults to 30s (matching the Python webhook_timeout).

func (*Dispatcher) Deliver

func (d *Dispatcher) Deliver(ctx context.Context, url, secret string, payload any) (*Delivery, error)

Deliver POSTs payload to url, signing it with secret. The returned Delivery records the outcome regardless of HTTP status — a non-2xx response is a delivery with Success=false, not a Go error. A Go error is returned only for payload marshaling failures (a programming error).

Jump to

Keyboard shortcuts

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