Help us shape the future of Go! Take the 2026 Go Developer Survey

storagecommit

package
v0.1.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultRequestTimeout = 15 * time.Second
	DefaultAttentionAfter = 15 * time.Minute
)
View Source
const MaxActiveAttemptsPerDataSet = 4

Variables

This section is empty.

Functions

func DecodeSubmission

func DecodeSubmission(value string) (storage.CommitSubmission, error)

func EncodeSubmission

func EncodeSubmission(submission storage.CommitSubmission) (string, error)

Types

type AddPiecesStatusChecker

type AddPiecesStatusChecker interface {
	GetAddPiecesStatus(context.Context, synapse.AddPiecesStatusInput) (synapse.PDPStatusResult, error)
}

type AdvanceInput

type AdvanceInput struct {
	Copy                model.StorageUploadCopy
	Binding             model.StorageDataSet
	Target              synapse.DataSetTarget
	Pieces              []storage.PieceInput
	RequireEligibleCopy bool
	OwnerTerminal       bool
}

type AdvanceResult

type AdvanceResult struct {
	State         AdvanceState
	ReleaseReason ReleaseReason
	AttemptID     string
	Confirmation  *storage.CommitResult
	AttentionCode AttentionCode
	Continue      bool
	// Cause carries the provider error behind a release so the caller can record
	// why the data set failed instead of a generic sentinel. It is set only on
	// ReleaseDataSetUnavailable and is nil everywhere else.
	Cause error
	// AttentionHeld carries the reservation's flagged-attempt count so the caller
	// can say why capacity is unavailable. It is set only on
	// AdvanceWaitingCapacity and is zero everywhere else.
	AttentionHeld int
}

type AdvanceState

type AdvanceState string
const (
	AdvanceWaitingCapacity AdvanceState = "waiting_capacity"
	AdvanceSubmitted       AdvanceState = "submitted"
	AdvancePending         AdvanceState = "pending"
	AdvanceReleased        AdvanceState = "released"
	AdvanceConfirmed       AdvanceState = "confirmed"
	AdvanceRejected        AdvanceState = "rejected"
	AdvanceNeedsAttention  AdvanceState = "needs_attention"
)

type Advancer

type Advancer struct {
	Store          Store
	StatusChecker  AddPiecesStatusChecker
	RequestTimeout time.Duration
	AttentionAfter time.Duration
	Now            func() time.Time
}

func (*Advancer) Advance

func (a *Advancer) Advance(ctx context.Context, input AdvanceInput) (AdvanceResult, error)

func (*Advancer) AdvanceUnavailable

func (a *Advancer) AdvanceUnavailable(
	ctx context.Context,
	copyRow model.StorageUploadCopy,
	binding model.StorageDataSet,
) (AdvanceResult, error)

AdvanceUnavailable records an attempted commit whose provider context could not be reconstructed. It never submits or confirms provider work.

func (*Advancer) ReleaseTerminalReservation

func (a *Advancer) ReleaseTerminalReservation(
	ctx context.Context,
	copyRow model.StorageUploadCopy,
	binding model.StorageDataSet,
) (AdvanceResult, error)

ReleaseTerminalReservation releases an unattempted reservation whose owner is terminal without requiring a provider context.

type AttemptInput

type AttemptInput struct {
	Copy         CopyIdentity
	AttemptID    string
	ExtraDataHex string
	Now          time.Time
}

type AttemptResult

type AttemptResult struct {
	Entered bool
	Copy    model.StorageUploadCopy
}

type AttentionCode

type AttentionCode string

AttentionCode identifies a durable commit that needs operator review.

const (
	AttentionAttemptOnlyAmbiguous AttentionCode = "attempt_only_ambiguous"
	AttentionUnattributedPiece    AttentionCode = "unattributed_piece"
	AttentionInvalidSubmission    AttentionCode = "invalid_submission"
	AttentionSubmissionMismatch   AttentionCode = "submission_mismatch"
	AttentionDataSetUnavailable   AttentionCode = "data_set_unavailable"
	AttentionConfirmationTimeout  AttentionCode = "confirmation_timeout"
)

func ParseAttentionCode

func ParseAttentionCode(value string) (AttentionCode, error)

func (AttentionCode) Valid

func (c AttentionCode) Valid() bool

type AttentionInput

type AttentionInput struct {
	Copy      CopyIdentity
	AttemptID string
	Code      AttentionCode
	Now       time.Time
}

type AttentionRecord

type AttentionRecord struct {
	CopyID        int64
	UploadID      int64
	CopyIndex     int
	DataSetRowID  int64
	ProviderID    string
	DataSetID     string
	PieceCID      string
	AttemptID     string
	TransactionID string
	Code          AttentionCode
	AttemptedAt   time.Time
	AttentionAt   time.Time
}

type CopyIdentity

type CopyIdentity struct {
	StorageUploadCopyID int64
	UploadID            int64
	CopyIndex           int
	StorageDataSetID    int64
	RequireEligibleCopy bool
}

type EvidenceInput

type EvidenceInput struct {
	Copy           CopyIdentity
	AttemptID      string
	TransactionID  string
	SubmissionJSON string
	Now            time.Time
}

type ManualReleaseInput

type ManualReleaseInput struct {
	CopyID                       int64
	ExpectedAttemptID            string
	AcknowledgePossibleDuplicate bool
	Now                          time.Time
}

type ReleaseInput

type ReleaseInput struct {
	Copy              CopyIdentity
	AttemptID         string
	KnownNotSubmitted bool
	ClearReadyAt      bool
	ClearExtraData    bool
	Now               time.Time
}

type ReleaseReason

type ReleaseReason string
const (
	ReleaseBeforeSubmitCanceled ReleaseReason = "before_submit_canceled"
	ReleaseDataSetUnavailable   ReleaseReason = "data_set_unavailable"
	ReleaseOwnerTerminal        ReleaseReason = "owner_terminal"
)

type ReservationReleaseInput

type ReservationReleaseInput struct {
	Copy           CopyIdentity
	ClearReadyAt   bool
	ClearExtraData bool
	Now            time.Time
}

type ReservationState

type ReservationState string
const (
	ReservationAcquired ReservationState = "acquired"
	ReservationWaiting  ReservationState = "waiting"
)

type ReserveInput

type ReserveInput struct {
	Copy      CopyIdentity
	AttemptID string
	Now       time.Time
}

type ReserveResult

type ReserveResult struct {
	State ReservationState
	Copy  model.StorageUploadCopy
	// AttentionHeld counts the data set's active attempts already flagged for
	// operator attention. It is set only when capacity turned the reservation
	// away, so a waiting result with zero here is queued behind work that is
	// still moving.
	AttentionHeld int
}

type ResetInput

type ResetInput struct {
	Copy      CopyIdentity
	AttemptID string
	LastError string
	Now       time.Time
}

type Store

type Store interface {
	ReserveCommitAttempt(context.Context, ReserveInput) (ReserveResult, error)
	MarkCommitAttempted(context.Context, AttemptInput) (AttemptResult, error)
	RecordCommitTransaction(context.Context, EvidenceInput) error
	RecordCommitSubmission(context.Context, EvidenceInput) error
	MarkCommitAttention(context.Context, AttentionInput) error
	ResetCommitAttempt(context.Context, ResetInput) error
	ReleaseCommitAttempt(context.Context, ReleaseInput) error
	ReleaseCommitReservation(context.Context, ReservationReleaseInput) error
}

Jump to

Keyboard shortcuts

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