Documentation
¶
Index ¶
Constants ¶
const ( DetailCurrentRevision = "current_revision" DetailLatestSnapshot = "latest_snapshot" DetailIdempotencyKey = "idempotency_key" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ErrorCode ¶
type ErrorCode string
ErrorCode is the stable text code exposed across transports.
func ErrorCodeOf ¶
ErrorCodeOf extracts the canonical sync error code when available.
type MutationInput ¶
type MutationInput struct {
ResourceRef ResourceRef `json:"resource_ref"`
Operation string `json:"operation"`
Payload []byte `json:"payload"`
ExpectedRevision int64 `json:"expected_revision"`
IdempotencyKey string `json:"idempotency_key,omitempty"`
// ActorID is required when IdempotencyKey is set so replay scope remains actor-isolated.
ActorID string `json:"actor_id,omitempty"`
ClientID string `json:"client_id,omitempty"`
CorrelationID string `json:"correlation_id,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
MutationInput is a single revision-aware write intent.
type MutationResult ¶
type MutationResult struct {
Snapshot Snapshot `json:"snapshot"`
Applied bool `json:"applied"`
Replay bool `json:"replay"`
}
MutationResult captures the authoritative outcome of a mutation attempt.
type ResourceRef ¶
type ResourceRef struct {
Kind string `json:"kind"`
ID string `json:"id"`
Scope map[string]string `json:"scope,omitempty"`
}
ResourceRef identifies a single mutable resource within a logical scope.
type Snapshot ¶
type Snapshot struct {
ResourceRef ResourceRef `json:"resource_ref"`
Data []byte `json:"data"`
Revision int64 `json:"revision"`
UpdatedAt time.Time `json:"updated_at"`
Metadata map[string]any `json:"metadata,omitempty"`
}
Snapshot is the latest known server-authored view of a resource.
type SyncError ¶
type SyncError struct {
Code ErrorCode `json:"code"`
Message string `json:"message"`
Details map[string]any `json:"details,omitempty"`
Err error `json:"-"`
}
SyncError is the canonical domain error shape used before transport mapping.
func NewStaleRevisionError ¶
NewStaleRevisionError builds the canonical stale-revision error shape.
func NewWrappedError ¶
NewWrappedError builds a canonical sync error that retains the original cause.
type SyncService ¶
type SyncService interface {
Get(ctx context.Context, ref ResourceRef) (Snapshot, error)
Mutate(ctx context.Context, input MutationInput) (MutationResult, error)
}
SyncService is the backend orchestration contract for revisioned resources.