webhookstore

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package webhookstore owns ordinary declared outbound webhook endpoint, signing-secret and delivery records. The public outbound package owns every state transition, encryption and network effect.

Index

Constants

This section is empty.

Variables

View Source
var Deliveries = orm.Define("foundry_webhook_deliveries", func(b orm.Builder[Delivery], m *Delivery) DeliveryTable {
	table := orm.TableOf(b, &m.ID)
	return DeliveryTable{Table: table, ID: table.Key(), EndpointID: orm.ColumnOf(b, &m.EndpointID), Event: orm.TextOf(b, &m.Event), Payload: orm.TextOf(b, &m.Payload), State: orm.TextOf(b, &m.State), Attempts: orm.NumberOf(b, &m.Attempts), LastStatus: orm.NumberOf(b, &m.LastStatus), LastFailure: orm.TextOf(b, &m.LastFailure), CreatedAt: orm.CreatedAtOf(b, &m.CreatedAt), UpdatedAt: orm.UpdatedAtOf(b, &m.UpdatedAt), DeliveredAt: orm.NullableTimeOf(b, &m.DeliveredAt)}
})

Deliveries owns the immutable Delivery declaration. Example: orm.First(ctx, tx, Deliveries.Query()).

View Source
var Endpoints = orm.Define("foundry_webhook_endpoints", func(b orm.Builder[Endpoint], m *Endpoint) EndpointTable {
	table := orm.TableOf(b, &m.ID)
	return EndpointTable{Table: table, ID: table.Key(), URL: orm.TextOf(b, &m.URL), Events: orm.JSONOf(b, &m.Events), Active: orm.ColumnOf(b, &m.Active), CreatedAt: orm.CreatedAtOf(b, &m.CreatedAt), UpdatedAt: orm.UpdatedAtOf(b, &m.UpdatedAt)}
})

Endpoints owns the immutable Endpoint declaration. Example: orm.First(ctx, tx, Endpoints.Query()).

View Source
var Secrets = orm.Define("foundry_webhook_secrets", func(b orm.Builder[Secret], m *Secret) SecretTable {
	table := orm.TableOf(b, &m.ID)
	return SecretTable{Table: table, ID: table.Key(), EndpointID: orm.ColumnOf(b, &m.EndpointID), Ciphertext: orm.TextOf(b, &m.Ciphertext), ExpiresAt: orm.NullableTimeOf(b, &m.ExpiresAt), CreatedAt: orm.TimeOf(b, &m.CreatedAt)}
})

Secrets owns the immutable Secret declaration. Example: orm.First(ctx, tx, Secrets.Query()).

Functions

This section is empty.

Types

type Delivery

type Delivery struct {
	ID          model.ID[Delivery]
	EndpointID  model.ID[Endpoint]
	Event       string
	Payload     string
	State       string
	Attempts    uint32
	LastStatus  int32
	LastFailure string
	// CreatedAt preserves explicit input; persistence supplies the owning clock when omitted.
	CreatedAt temporal.DateTime
	// UpdatedAt is refreshed from the owning clock after before-write hooks and before mutators.
	UpdatedAt   temporal.DateTime
	DeliveredAt value.Nullable[temporal.DateTime]
}

Delivery is the delivery log and durable payload of one message. Its ID is the stable webhook-id across attempts and replays.

func (Delivery) Format

func (Delivery) Format(s fmt.State, _ rune)

type DeliveryTable

type DeliveryTable struct {
	// Table provides model queries and writes. Example: orm.First(ctx, tx, Deliveries.Query()).
	orm.Table[Delivery, model.ID[Delivery]]
	// ID binds Delivery.ID.
	// Example: orm.KeySet(Deliveries.ID, id).
	ID orm.Key[Delivery, model.ID[Delivery]]
	// EndpointID binds Delivery.EndpointID.
	// Example: orm.ColumnSet(Deliveries.EndpointID, endpointID).
	EndpointID orm.Column[Delivery, model.ID[Endpoint]]
	// Event binds Delivery.Event.
	// Example: orm.TextSet(Deliveries.Event, event).
	Event orm.Text[Delivery, string]
	// Payload binds Delivery.Payload.
	// Example: orm.TextSet(Deliveries.Payload, payload).
	Payload orm.Text[Delivery, string]
	// State binds Delivery.State.
	// Example: orm.TextSet(Deliveries.State, state).
	State orm.Text[Delivery, string]
	// Attempts binds Delivery.Attempts.
	// Example: orm.NumberSet(Deliveries.Attempts, attempts).
	Attempts orm.Number[Delivery, uint32]
	// LastStatus binds Delivery.LastStatus.
	// Example: orm.NumberSet(Deliveries.LastStatus, lastStatus).
	LastStatus orm.Number[Delivery, int32]
	// LastFailure binds Delivery.LastFailure.
	// Example: orm.TextSet(Deliveries.LastFailure, lastFailure).
	LastFailure orm.Text[Delivery, string]
	// CreatedAt preserves an explicit creation time; the owning clock supplies omitted values.
	// Example: orm.TimeSet(Deliveries.CreatedAt, createdAt).
	CreatedAt orm.CreatedAt[Delivery, temporal.DateTime]
	// UpdatedAt is replaced by the owning clock after before-write hooks and before mutators.
	// Example: orm.TimeSet(Deliveries.UpdatedAt, updatedAt).
	UpdatedAt orm.UpdatedAt[Delivery, temporal.DateTime]
	// DeliveredAt binds Delivery.DeliveredAt.
	// Example: orm.NullableTimeSetNull(Deliveries.DeliveredAt).
	DeliveredAt orm.NullableTime[Delivery, temporal.DateTime]
}

DeliveryTable binds the persisted Delivery columns. Example: Deliveries.Query().Limit(10).

type Endpoint

type Endpoint struct {
	ID     model.ID[Endpoint]
	URL    string
	Events value.JSON[[]string]
	Active bool
	// CreatedAt preserves explicit input; persistence supplies the owning clock when omitted.
	CreatedAt temporal.DateTime
	// UpdatedAt is refreshed from the owning clock after before-write hooks and before mutators.
	UpdatedAt temporal.DateTime
}

func (Endpoint) Format

func (Endpoint) Format(s fmt.State, _ rune)

type EndpointTable

type EndpointTable struct {
	// Table provides model queries and writes. Example: orm.First(ctx, tx, Endpoints.Query()).
	orm.Table[Endpoint, model.ID[Endpoint]]
	// ID binds Endpoint.ID.
	// Example: orm.KeySet(Endpoints.ID, id).
	ID orm.Key[Endpoint, model.ID[Endpoint]]
	// URL binds Endpoint.URL.
	// Example: orm.TextSet(Endpoints.URL, url).
	URL orm.Text[Endpoint, string]
	// Events binds Endpoint.Events.
	// Example: encoded, err := value.NewJSON(events); if err == nil { _ = orm.JSONSet(Endpoints.Events, encoded) }.
	Events orm.JSON[Endpoint, []string]
	// Active binds Endpoint.Active.
	// Example: orm.ColumnSet(Endpoints.Active, active).
	Active orm.Column[Endpoint, bool]
	// CreatedAt preserves an explicit creation time; the owning clock supplies omitted values.
	// Example: orm.TimeSet(Endpoints.CreatedAt, createdAt).
	CreatedAt orm.CreatedAt[Endpoint, temporal.DateTime]
	// UpdatedAt is replaced by the owning clock after before-write hooks and before mutators.
	// Example: orm.TimeSet(Endpoints.UpdatedAt, updatedAt).
	UpdatedAt orm.UpdatedAt[Endpoint, temporal.DateTime]
}

EndpointTable binds the persisted Endpoint columns. Example: Endpoints.Query().Limit(10).

type Secret

type Secret struct {
	ID         model.ID[Secret]
	EndpointID model.ID[Endpoint]
	Ciphertext string
	ExpiresAt  value.Nullable[temporal.DateTime]
	CreatedAt  temporal.DateTime
}

Secret stores one encrypted signing secret. A null ExpiresAt marks the current secret; a rotated secret keeps signing until it expires.

func (Secret) Format

func (Secret) Format(s fmt.State, _ rune)

type SecretTable

type SecretTable struct {
	// Table provides model queries and writes. Example: orm.First(ctx, tx, Secrets.Query()).
	orm.Table[Secret, model.ID[Secret]]
	// ID binds Secret.ID.
	// Example: orm.KeySet(Secrets.ID, id).
	ID orm.Key[Secret, model.ID[Secret]]
	// EndpointID binds Secret.EndpointID.
	// Example: orm.ColumnSet(Secrets.EndpointID, endpointID).
	EndpointID orm.Column[Secret, model.ID[Endpoint]]
	// Ciphertext binds Secret.Ciphertext.
	// Example: orm.TextSet(Secrets.Ciphertext, ciphertext).
	Ciphertext orm.Text[Secret, string]
	// ExpiresAt binds Secret.ExpiresAt.
	// Example: orm.NullableTimeSetNull(Secrets.ExpiresAt).
	ExpiresAt orm.NullableTime[Secret, temporal.DateTime]
	// CreatedAt preserves an explicit creation time; callers supply this timestamp.
	// Example: orm.TimeSet(Secrets.CreatedAt, createdAt).
	CreatedAt orm.Time[Secret, temporal.DateTime]
}

SecretTable binds the persisted Secret columns. Example: Secrets.Query().Limit(10).

Jump to

Keyboard shortcuts

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