webhookdeliverypostgres

package
v3.1.2 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package webhookdeliverypostgres provides a supported Postgres-backed registry, delivery store, attempt recorder, and replay adapter for contrib/webhookdelivery. Endpoint URL validation uses the shared webhookdelivery.EndpointPolicy option so production defaults stay strict while explicit local-development policies can allow HTTP endpoints.

Index

Constants

View Source
const (

	// OutboxEventType is the durable async job type used for webhook deliveries.
	OutboxEventType = "webhook.delivery"
)

Variables

View Source
var (
	// ErrInvalidTable reports that a configured table name is not a safe SQL identifier.
	ErrInvalidTable = errors.New("invalid webhook delivery table")
	// ErrStoreNotConfigured reports that the store or pool was not configured.
	ErrStoreNotConfigured = errors.New("webhook delivery postgres store not configured")
	// ErrSecretResolverRequired reports that endpoint signing secrets cannot be loaded.
	ErrSecretResolverRequired = errors.New("webhook signing secret resolver required")
	// ErrSecretNotFound reports that a tenant-scoped endpoint secret is missing.
	ErrSecretNotFound = errors.New("webhook signing secret not found")
	// ErrDeliveryNotFound reports a missing tenant-scoped delivery row.
	ErrDeliveryNotFound = errors.New("webhook delivery not found")
)

Functions

This section is empty.

Types

type Options

type Options struct {
	EndpointTable  string
	DeliveryTable  string
	OutboxTable    string
	Clock          func() time.Time
	SecretResolver SecretResolver
	TxManager      ports.TxManager
	EndpointPolicy webhookdelivery.EndpointPolicy
}

Options configures the Postgres webhook delivery store.

type SecretResolver

type SecretResolver interface {
	ResolveSigningSecret(ctx context.Context, tenantID, endpointID string) ([]byte, bool, error)
}

SecretResolver loads endpoint signing material from application-owned secret storage.

type SecretResolverFunc

type SecretResolverFunc func(context.Context, string, string) ([]byte, bool, error)

SecretResolverFunc adapts a function to SecretResolver.

func (SecretResolverFunc) ResolveSigningSecret

func (f SecretResolverFunc) ResolveSigningSecret(ctx context.Context, tenantID, endpointID string) ([]byte, bool, error)

ResolveSigningSecret loads endpoint signing material.

type Store

type Store struct {
	Pool ports.DatabasePool
	// contains filtered or unexported fields
}

Store implements tenant-scoped webhook endpoint lookup, delivery enqueue, attempt recording, and replay scheduling over Postgres tables.

func New

func New(pool ports.DatabasePool, opts Options) *Store

New creates a Postgres-backed webhook delivery store.

func (*Store) EnqueueDelivery

func (s *Store) EnqueueDelivery(ctx context.Context, delivery webhookdelivery.Delivery, job webhookdelivery.JobPayload) error

EnqueueDelivery inserts a delivery row and matching outbox job in one transaction.

func (*Store) GetEndpoint

func (s *Store) GetEndpoint(ctx context.Context, tenantID, endpointID string) (webhookdelivery.Endpoint, bool, error)

GetEndpoint returns one tenant-scoped endpoint.

func (*Store) HealthChecker

func (s *Store) HealthChecker() ports.HealthChecker

HealthChecker returns a Postgres webhook delivery dependency health checker.

func (*Store) ListEndpoints

func (s *Store) ListEndpoints(ctx context.Context, tenantID, eventType string) ([]webhookdelivery.Endpoint, error)

ListEndpoints returns enabled tenant endpoints subscribed to eventType.

func (*Store) RecordAttempt

func (s *Store) RecordAttempt(ctx context.Context, result webhookdelivery.AttemptResult) error

RecordAttempt stores a sanitized delivery attempt outcome.

func (*Store) ReplayDelivery

func (s *Store) ReplayDelivery(ctx context.Context, tenantID, deliveryID string, nextAt time.Time) error

ReplayDelivery schedules a tenant-scoped delivery for another attempt.

Jump to

Keyboard shortcuts

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