Documentation
¶
Overview ¶
Package output owns native resumable receive output, task locking, journal persistence, compatible-name mapping, and recovery inventory.
Index ¶
- Constants
- Variables
- func DiagnoseFailure(stage FailureStage, cause error) error
- func FailureForStage(cause error, stage FailureStage) error
- func OpenContainer(path string, create bool) (*Dir, RootDisposition, error)
- func PortableName(name string) bool
- func SanitizeCandidate(operationID []byte, logicalPath string, attempt uint32) (string, error)
- func ValidComponent(name string) error
- type ActiveLookup
- type AttentionError
- type AttentionReason
- type Authority
- func (a *Authority) BindDestination(ctx context.Context) (resultErr error)
- func (a *Authority) Close() error
- func (a *Authority) CreateOperation(ctx context.Context, lookup ActiveLookup, ...) (_ *Operation, resultErr error)
- func (a *Authority) OpenOperation(ctx context.Context, op *Operation) (transfer.DirectTreeSession, error)
- func (a *Authority) SelectOperation(ctx context.Context, selection transfer.SelectionSpec, ...) (result ActiveLookup, resultErr error)
- type Config
- type DestinationCapabilities
- type Diagnostic
- type Dir
- type DirLock
- type EntryKind
- type FailureStage
- type FileLock
- type LookupKind
- type NameAdjustment
- type NameAdjustmentSummary
- type NameMapping
- type NativeErrorClass
- type Operation
- type RecoveryInventory
- type RecoveryItem
- type RecoveryItemBlockReason
- type RecoveryItemState
- type RecoveryListStatus
- type RecoveryOperationState
- type RecoverySummary
- func (s RecoverySummary) Busy() bool
- func (s RecoverySummary) Items() []RecoveryItem
- func (s RecoverySummary) NeedsAttentionReason() AttentionReason
- func (s RecoverySummary) OperationID() receivecontract.OperationID
- func (s RecoverySummary) ReceiveIntentDigest() transfer.ReceiveIntentDigest
- func (s RecoverySummary) State() RecoveryOperationState
- func (s RecoverySummary) StateGeneration() uint64
- func (s RecoverySummary) Valid() bool
- type RootDisposition
- type Session
- func (s *Session) AdmitDirectory(ctx context.Context, request transfer.DirectoryMaterializationRequest) (transfer.DirectoryAdmission, error)
- func (s *Session) BeginFile(ctx context.Context, file transfer.MaterializationFile) (transfer.FileStart, error)
- func (s *Session) Capabilities() transfer.DirectTreeCapabilities
- func (s *Session) FinalizeDirectory(ctx context.Context, admission transfer.DirectoryAdmission) (transfer.DirectorySettlement, error)
- func (s *Session) FinalizeTree(ctx context.Context, outcome transfer.DirectTreeOutcome) (transfer.DirectTreeSettlement, error)
- func (s *Session) LookupDelivery(ctx context.Context, fileID catalog.FileID, materializationRelativePath string) (transfer.HistoricalDelivery, bool, error)
- func (s *Session) PauseTree(ctx context.Context) (transfer.DirectTreeSettlement, error)
- func (s *Session) SessionID() transfer.OutputSessionID
Constants ¶
const ( MaxPortableNameBytes = 255 MaxNameRepairAttempts = 16 MaxNameMappings = 65_536 MaxNameAdjustmentSamples = 20 )
const ( // SmallFileThreshold separates single-shot small files (0 per-file fsync on // the hot path; batched journal sync) from large files that stream range // checkpoints to disk during transfer. SmallFileThreshold uint64 = 8 << 20 // 8 MiB LargeCheckpointBytes uint64 = 8 << 20 // 8 MiB // LargeCheckpointInterval caps checkpoint lag during slow trickle writes // without spawning background idle timers; it is checked passively in Accept // while Pause and Commit flush any remaining bytes on stall, stop, or finish. LargeCheckpointInterval = 2 * time.Second )
const ( // ControlDirName holds all private WindShare receive state inside the // destination container so user output trees stay clean. ControlDirName = ".windshare-tmp" )
Variables ¶
var ( ErrOutOfRange = errors.New("osfs: range write is out of bounds or overlaps") ErrPathEscape = errors.New("osfs: path escapes output root") ErrBusy = errors.New("retained output operation is currently active") ErrAlreadyRunning = errors.New("matching output operation is already running") ErrAmbiguous = errors.New("matching output operation ownership is ambiguous") ErrOperationChanged = errors.New("retained output operation no longer matches") ErrInvalidContract = errors.New("native recovery contract is invalid") ErrUnsafeNamespace = errors.New("osfs: output namespace is unsafe") ErrNamespaceCollision = errors.New("osfs: output namespace entry already exists") ErrNameRejected = errors.New("osfs: destination rejects the output name") ErrNamespaceLockBusy = errors.New("osfs: output namespace lock is already held") ErrUnsupportedOutput = errors.New("osfs: recoverable native output is unsupported by the destination") )
var ErrInvalidNameMapping = errors.New("output name mapping is invalid")
Functions ¶
func DiagnoseFailure ¶
func DiagnoseFailure(stage FailureStage, cause error) error
func FailureForStage ¶
func FailureForStage(cause error, stage FailureStage) error
FailureForStage extracts causes owned by one failure stage from an error tree. A FailureClose boundary claims every cause inside it so release failures stay separate from earlier operation failures.
func OpenContainer ¶
func OpenContainer(path string, create bool) (*Dir, RootDisposition, error)
OpenContainer opens an existing destination directory (following a final symlink/junction once through the kernel) or creates it when create is true.
func PortableName ¶
PortableName reports whether name is safe across Windows, macOS, and Linux filesystems. Original source names are attempted natively first; PortableName governs generated repair names and fast-path checks.
func SanitizeCandidate ¶
SanitizeCandidate builds a deterministic cross-platform filename while keeping a readable stem and safe extension.
func ValidComponent ¶
Types ¶
type ActiveLookup ¶
type ActiveLookup struct {
// contains filtered or unexported fields
}
func (ActiveLookup) Attention ¶
func (l ActiveLookup) Attention() AttentionReason
func (ActiveLookup) Kind ¶
func (l ActiveLookup) Kind() LookupKind
func (ActiveLookup) Operation ¶
func (l ActiveLookup) Operation() *Operation
type AttentionError ¶
type AttentionError struct {
Reason AttentionReason
}
AttentionError preserves the attention reason when CreateOperation re-checks an automatic selection and encounters a damaged existing operation.
func (*AttentionError) Error ¶
func (err *AttentionError) Error() string
type AttentionReason ¶
type AttentionReason string
const ( AttentionNone AttentionReason = "" AttentionDestination AttentionReason = "destination-ownership-unknown" AttentionRegistry AttentionReason = "registry-ownership-unknown" AttentionLease AttentionReason = "lease-ownership-unknown" AttentionOperation AttentionReason = "operation-ownership-unknown" AttentionCleanup AttentionReason = "cleanup-uncertain" )
func (AttentionReason) Valid ¶
func (reason AttentionReason) Valid() bool
type Authority ¶
type Authority struct {
// contains filtered or unexported fields
}
Authority owns one caller-selected destination container across destination binding, operation lookup/creation, and active receive session lifecycle.
func (*Authority) BindDestination ¶
func (*Authority) CreateOperation ¶
func (a *Authority) CreateOperation( ctx context.Context, lookup ActiveLookup, artifact receivecontract.ArtifactSpec, ) (_ *Operation, resultErr error)
func (*Authority) OpenOperation ¶
func (*Authority) SelectOperation ¶
func (a *Authority) SelectOperation( ctx context.Context, selection transfer.SelectionSpec, selector receivecontract.OperationSelection, ) (result ActiveLookup, resultErr error)
type DestinationCapabilities ¶
type DestinationCapabilities struct {
SafePublish bool
SafePublishReason string
OperationRecovery bool
OperationRecoveryReason string
// contains filtered or unexported fields
}
DestinationCapabilities reports whether the destination supports atomic no-replace publication required for safe resumable downloads.
func ProbeDestination ¶
func ProbeDestination(root *Dir) (caps DestinationCapabilities, resultErr error)
ProbeDestination verifies that the destination filesystem supports atomic no-replace file publication using a temporary scratch directory that is removed before returning.
func (DestinationCapabilities) Valid ¶
func (c DestinationCapabilities) Valid() bool
func (DestinationCapabilities) ValidateSupport ¶
func (c DestinationCapabilities) ValidateSupport() error
type Diagnostic ¶
type Diagnostic struct {
Stage FailureStage
NativeErrorClass NativeErrorClass
Fault transferfault.Fault
}
Diagnostic is value-only native failure evidence extracted at adapter edges.
func DiagnosticFor ¶
func DiagnosticFor(err error) (Diagnostic, bool)
func (Diagnostic) Valid ¶
func (diagnostic Diagnostic) Valid() bool
type Dir ¶
type Dir struct {
// contains filtered or unexported fields
}
Dir is an open, verified directory handle that pins the directory without repeatedly opening and closing os.Root on every child syscall.
func (*Dir) SameDirectory ¶
type DirLock ¶
type DirLock struct {
// contains filtered or unexported fields
}
DirLock holds an exclusive destination-scoped OS coordination lock anchored to the destination container itself rather than a file inside .windshare-tmp, allowing .windshare-tmp to be created and removed while locked. Callers must release a DirLock on the same goroutine that acquired it.
type FailureStage ¶
type FailureStage uint8
const ( FailureDestinationBinding FailureStage = iota + 1 FailureInventory FailureLookup FailureOpen FailureCreate FailureCheckpoint FailureDurability FailureClose )
func (FailureStage) String ¶
func (stage FailureStage) String() string
func (FailureStage) Valid ¶
func (stage FailureStage) Valid() bool
type FileLock ¶
type FileLock struct {
// contains filtered or unexported fields
}
FileLock holds a non-blocking exclusive OS-level task file lock (flock / LockFileEx).
type LookupKind ¶
type LookupKind uint8
const ( LookupCreateReady LookupKind = iota + 1 LookupNotFound LookupReopened LookupAlreadyRunning LookupNeedsAttention LookupAmbiguous )
type NameAdjustment ¶
NameAdjustment records one logical name or path saved under a compatible physical spelling: relative to the destination directory for nested items, or the destination entry name itself when the top-level root or single file was repaired.
type NameAdjustmentSummary ¶
type NameAdjustmentSummary struct {
Count uint64
Samples []NameAdjustment
}
NameAdjustmentSummary is a bounded value snapshot of compatible-name repairs materialized by an operation. Count is exact; Samples is capped.
func (NameAdjustmentSummary) Clone ¶
func (s NameAdjustmentSummary) Clone() NameAdjustmentSummary
type NameMapping ¶
type NameMapping struct {
LogicalPath string `json:"logical"`
PhysicalComponent string `json:"physical"`
Attempt uint32 `json:"attempt"`
Directory bool `json:"dir,omitempty"`
}
NameMapping persists one logical-to-physical component repair so restarts reuse the exact same destination spelling.
type NativeErrorClass ¶
type NativeErrorClass uint8
const ( NativeErrorAccessDenied NativeErrorClass = iota + 1 NativeErrorSharingViolation NativeErrorNotFound NativeErrorInvalidHandle NativeErrorUnsupported NativeErrorIO NativeErrorUnknown )
func ClassifyNativeError ¶
func ClassifyNativeError(err error) (NativeErrorClass, bool)
ClassifyNativeError maps an underlying OS error into a closed diagnostic class so higher layers can present bounded guidance without leaking host paths.
func (NativeErrorClass) String ¶
func (class NativeErrorClass) String() string
func (NativeErrorClass) Valid ¶
func (class NativeErrorClass) Valid() bool
type Operation ¶
type Operation struct {
// contains filtered or unexported fields
}
Operation owns an active task lock, journal, and top-level destination root for one receive intent.
func (*Operation) NameAdjustments ¶
func (op *Operation) NameAdjustments() NameAdjustmentSummary
func (*Operation) ReceiveIntent ¶
func (op *Operation) ReceiveIntent() (transfer.ReceiveIntent, bool)
type RecoveryInventory ¶
type RecoveryInventory struct {
// contains filtered or unexported fields
}
func ListOperations ¶
func ListOperations(ctx context.Context, rootPath string) (RecoveryInventory, error)
ListOperations inspects retained native operations under <rootPath>/.windshare-tmp without creating or modifying anything when no control directory exists.
func (RecoveryInventory) Status ¶
func (inv RecoveryInventory) Status() RecoveryListStatus
func (RecoveryInventory) Summaries ¶
func (inv RecoveryInventory) Summaries() []RecoverySummary
func (RecoveryInventory) UnknownEntries ¶
func (inv RecoveryInventory) UnknownEntries() bool
type RecoveryItem ¶
type RecoveryItem struct {
// contains filtered or unexported fields
}
func (RecoveryItem) BlockReason ¶
func (i RecoveryItem) BlockReason() RecoveryItemBlockReason
func (RecoveryItem) CanonicalPath ¶
func (i RecoveryItem) CanonicalPath() string
func (RecoveryItem) Reference ¶
func (i RecoveryItem) Reference() string
func (RecoveryItem) State ¶
func (i RecoveryItem) State() RecoveryItemState
type RecoveryItemBlockReason ¶
type RecoveryItemBlockReason uint8
const ( RecoveryItemBlockNone RecoveryItemBlockReason = iota RecoveryItemBlockPublicationUnknown RecoveryItemBlockCheckpointInvalid RecoveryItemBlockOwnedObjectUnknown RecoveryItemBlockRevisionConflict )
type RecoveryItemState ¶
type RecoveryItemState uint8
const ( RecoveryItemIncomplete RecoveryItemState = iota + 1 RecoveryItemResumable RecoveryItemPublished RecoveryItemFailed RecoveryItemBlocked )
type RecoveryListStatus ¶
type RecoveryListStatus uint8
const ( RecoveryListReady RecoveryListStatus = iota + 1 RecoveryListNeedsAttention )
type RecoveryOperationState ¶
type RecoveryOperationState uint8
const ( RecoveryOperationIncomplete RecoveryOperationState = iota + 1 RecoveryOperationResumable RecoveryOperationCleanupPending RecoveryOperationNeedsAttention RecoveryOperationDiscarded )
type RecoverySummary ¶
type RecoverySummary struct {
// contains filtered or unexported fields
}
func DiscardOperation ¶
func DiscardOperation( ctx context.Context, rootPath string, opID receivecontract.OperationID, ) (summary RecoverySummary, resultErr error)
DiscardOperation deletes WindShare's private scratch directory for opID while preserving every published and foreign file in the user's destination.
func (RecoverySummary) Busy ¶
func (s RecoverySummary) Busy() bool
func (RecoverySummary) Items ¶
func (s RecoverySummary) Items() []RecoveryItem
func (RecoverySummary) NeedsAttentionReason ¶
func (s RecoverySummary) NeedsAttentionReason() AttentionReason
func (RecoverySummary) OperationID ¶
func (s RecoverySummary) OperationID() receivecontract.OperationID
func (RecoverySummary) ReceiveIntentDigest ¶
func (s RecoverySummary) ReceiveIntentDigest() transfer.ReceiveIntentDigest
func (RecoverySummary) State ¶
func (s RecoverySummary) State() RecoveryOperationState
func (RecoverySummary) StateGeneration ¶
func (s RecoverySummary) StateGeneration() uint64
func (RecoverySummary) Valid ¶
func (s RecoverySummary) Valid() bool
type RootDisposition ¶
type RootDisposition uint8
const ( CallerProvidedContainer RootDisposition = iota + 1 AuthorityCreatedRoot )
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session implements transfer.DirectTreeSession and transfer.DeliveryHistory directly over an active Operation's journal and open directory handles.
Session entry points serialize state transitions and shared directory handle lifetimes under s.mu (order: tx.mu -> s.mu -> nameMapper.mu -> journal.mu), while per-file data writes and publication run independently under tx.mu.
func (*Session) AdmitDirectory ¶
func (s *Session) AdmitDirectory( ctx context.Context, request transfer.DirectoryMaterializationRequest, ) (transfer.DirectoryAdmission, error)
func (*Session) Capabilities ¶
func (s *Session) Capabilities() transfer.DirectTreeCapabilities
func (*Session) FinalizeDirectory ¶
func (s *Session) FinalizeDirectory( ctx context.Context, admission transfer.DirectoryAdmission, ) (transfer.DirectorySettlement, error)
func (*Session) FinalizeTree ¶
func (s *Session) FinalizeTree( ctx context.Context, outcome transfer.DirectTreeOutcome, ) (transfer.DirectTreeSettlement, error)
func (*Session) LookupDelivery ¶
func (*Session) SessionID ¶
func (s *Session) SessionID() transfer.OutputSessionID