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
- Variables
- type Options
- type SecretResolver
- type SecretResolverFunc
- type Store
- func (s *Store) EnqueueDelivery(ctx context.Context, delivery webhookdelivery.Delivery, ...) error
- func (s *Store) GetEndpoint(ctx context.Context, tenantID, endpointID string) (webhookdelivery.Endpoint, bool, error)
- func (s *Store) HealthChecker() ports.HealthChecker
- func (s *Store) ListEndpoints(ctx context.Context, tenantID, eventType string) ([]webhookdelivery.Endpoint, error)
- func (s *Store) RecordAttempt(ctx context.Context, result webhookdelivery.AttemptResult) error
- func (s *Store) ReplayDelivery(ctx context.Context, tenantID, deliveryID string, nextAt time.Time) error
Constants ¶
const (
// OutboxEventType is the durable async job type used for webhook deliveries.
OutboxEventType = "webhook.delivery"
)
Variables ¶
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 ¶
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.