Documentation
¶
Overview ¶
Package teamintent records team namespace intent in the platform transaction.
Index ¶
- Variables
- type OperationAcceptance
- type OperationRequest
- type Writer
- func (w *Writer) ClaimFence(ctx context.Context, teamID, workerID string) (apikit.TeamIntentFenceResponse, error)
- func (w *Writer) ClaimObserverLease(ctx context.Context, clusterKey, observerID string) (apikit.TeamIntentObserverLeaseResponse, error)
- func (w *Writer) GetIntent(ctx context.Context, teamID string) (apikit.TeamNamespaceIntent, bool, error)
- func (w *Writer) GetOperation(ctx context.Context, operationID, actorID string) (OperationAcceptance, bool, error)
- func (w *Writer) ListIntents(ctx context.Context) ([]apikit.TeamNamespaceIntent, error)
- func (w *Writer) LookupAcceptance(ctx context.Context, tx *sql.Tx, actorID, kind, key, requestHash string) (OperationAcceptance, bool, error)
- func (w *Writer) Record(ctx context.Context, tx *sql.Tx, teamID string, deleted bool) error
- func (w *Writer) RecordAcceptance(ctx context.Context, tx *sql.Tx, request OperationRequest) (OperationAcceptance, error)
- func (w *Writer) RecordObservation(ctx context.Context, teamID string, req apikit.TeamIntentObservationRequest) (apikit.TeamNamespaceObservation, error)
- func (w *Writer) RecordReceipt(ctx context.Context, teamID string, req apikit.TeamIntentReceiptRequest) (apikit.TeamNamespaceReceipt, error)
- func (w *Writer) RecordWithOperation(ctx context.Context, tx *sql.Tx, teamID string, deleted bool, ...) (string, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDisabled is returned when PLATFORM_TEAM_INTENT_JOURNAL is not enabled. ErrDisabled = errors.New("team intent journal is disabled") // ErrStaleReceipt is returned when a worker receipt fails fence, revision, // or incarnation ownership validation. ErrStaleReceipt = errors.New("stale team intent receipt") // ErrStaleObservation is returned when an observer epoch, revision, or UID // fails conditional validation. ErrStaleObservation = errors.New("stale team intent observation") // ErrInvalidInput is returned when a team intent API request is malformed. ErrInvalidInput = errors.New("invalid team intent request") )
var ErrIdempotencyConflict = errors.New("idempotency key already accepted different input")
ErrIdempotencyConflict rejects reusing an actor/action replay key for different normalized input without changing the original acceptance.
Functions ¶
This section is empty.
Types ¶
type OperationAcceptance ¶
OperationAcceptance includes the immutable accepted team representation. Actor and replay metadata stay in storage and are not part of the wire shape.
type OperationRequest ¶
type OperationRequest struct {
ID string
RevisionID string
ActorID string
Kind string
IdempotencyKey string
RequestHash string
Team apikit.Team
}
OperationRequest binds immutable accepted contents to the authenticated request's replay scope and the revision enqueued in the same transaction.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer owns the insert-only River client and team intent persistence.
func Open ¶
Open prepares storage for the opt-in team journal. The DSN must point to the same PostgreSQL database as db and support session-level advisory locks.
func (*Writer) ClaimFence ¶
func (w *Writer) ClaimFence(ctx context.Context, teamID, workerID string) (apikit.TeamIntentFenceResponse, error)
ClaimFence atomically bumps the per-team execution fence epoch and returns the authoritative current desired intent.
func (*Writer) ClaimObserverLease ¶
func (w *Writer) ClaimObserverLease(ctx context.Context, clusterKey, observerID string) (apikit.TeamIntentObserverLeaseResponse, error)
ClaimObserverLease atomically increments the monotonic observer epoch for clusterKey so older observers cannot overwrite fresher observations.
func (*Writer) GetIntent ¶
func (w *Writer) GetIntent(ctx context.Context, teamID string) (apikit.TeamNamespaceIntent, bool, error)
GetIntent returns the authoritative desired intent for one team incarnation.
func (*Writer) GetOperation ¶
func (w *Writer) GetOperation(ctx context.Context, operationID, actorID string) (OperationAcceptance, bool, error)
GetOperation is actor-scoped even when an operation UUID is guessed or copied.
func (*Writer) ListIntents ¶
ListIntents returns all recorded team namespace intents with their latest receipts and independent observations.
func (*Writer) LookupAcceptance ¶
func (w *Writer) LookupAcceptance(ctx context.Context, tx *sql.Tx, actorID, kind, key, requestHash string) (OperationAcceptance, bool, error)
LookupAcceptance serializes only requests for the same actor/action/key for the lifetime of tx. Hash collisions can serialize unrelated requests but cannot make one actor observe another actor's acceptance.
func (*Writer) Record ¶
Record stores the latest desired revision for the team ID and schedules its job using the same transaction that changes the team. The caller owns commit and rollback.
func (*Writer) RecordAcceptance ¶
func (w *Writer) RecordAcceptance(ctx context.Context, tx *sql.Tx, request OperationRequest) (OperationAcceptance, error)
RecordAcceptance persists the immutable accepted contents and their operation in the caller's domain/intent/River transaction. Only lifecycle columns change later; receipts never replace this snapshot with current resource contents.
func (*Writer) RecordObservation ¶
func (w *Writer) RecordObservation(ctx context.Context, teamID string, req apikit.TeamIntentObservationRequest) (apikit.TeamNamespaceObservation, error)
RecordObservation persists independent Kubernetes health observations for a team incarnation without modifying desired intent, receipts, or River jobs.
func (*Writer) RecordReceipt ¶
func (w *Writer) RecordReceipt(ctx context.Context, teamID string, req apikit.TeamIntentReceiptRequest) (apikit.TeamNamespaceReceipt, error)
RecordReceipt stores a worker execution receipt conditional on the team incarnation, current desired revision, and execution fence epoch.
func (*Writer) RecordWithOperation ¶
func (w *Writer) RecordWithOperation(ctx context.Context, tx *sql.Tx, teamID string, deleted bool, operationID string) (string, error)
RecordWithOperation records the same transactional intent and queue payload, optionally linking it to the public acceptance operation created by the caller.