Skip to main content

internal/infra/pg/observationretry.go

internal/infra/pg · 148 lines · 5 declarations · source

Declarations​

var ErrInvalidIdempotencyKey, ErrIdempotencyConflict, ErrIngestionCapacity​

var (
ErrInvalidIdempotencyKey = errors.New("idempotency key must be a UUID")
ErrIdempotencyConflict = errors.New("idempotency key already identifies a different or erased observation")
ErrIngestionCapacity = errors.New("unfinished observation capacity is full")
)

source

method ObservationStore.AppendIdempotent​

func (s *ObservationStore) AppendIdempotent(ctx context.Context, schema Schema, turn domain.Turn, key string) (out domain.Observation, replayed bool, err error)

AppendIdempotent returns the original receipt for the same logical write. No key means an intentional new observation, even if its content repeats. Keys are project-scoped UUIDs; only a digest is stored. A tombstone survives erasure, without the payload digest or source identifier.

source

type retryMessage​

type retryMessage struct {
Ordinal int `json:"ordinal"`
Role domain.Role `json:"role"`
Content string `json:"content"`
GroupOrdinal int `json:"group_ordinal"`
}

retryRepresentation is what a retry receipt fingerprints: the turn without its times. When a turn happened is the application's claim about it, the first accepted claim stands, and a retry carrying another time is the same turn. Changing it changes which retries replay, so it is a decision, not a refactor; Version names the shape so two shapes can never compare equal.

source

type retryTurn​

type retryTurn struct {
Version int `json:"version"`
Scope string `json:"scope"`
DataSubjectID string `json:"data_subject_id"`
Messages []retryMessage `json:"messages"`
}

source

func retryRepresentation​

func retryRepresentation(turn domain.Turn) retryTurn

source