Documentation
¶
Overview ¶
Package transfer manages authorized, single-use file transfer tasks. It is independent of MCP sessions so a task can outlive its creation request.
Index ¶
- Variables
- type Direction
- type Journal
- type Lease
- func (l *Lease) BeginCommit() (context.Context, error)
- func (l *Lease) Close() error
- func (l *Lease) Complete() (Status, error)
- func (l *Lease) ConfirmTemporary() error
- func (l *Lease) Context() context.Context
- func (l *Lease) Fail(cause error) (Status, error)
- func (l *Lease) Progress(bytes int64) error
- func (l *Lease) RejectCommit(cause error) (Status, error)
- func (l *Lease) Spec() Spec
- func (l *Lease) Temporary() (string, error)
- func (l *Lease) Verify(bytes int64, digest string) error
- type Limits
- type Manager
- func (m *Manager) Authenticate(id, token string) (Status, error)
- func (m *Manager) Cancel(scope, id string) (Status, error)
- func (m *Manager) CancelWithToken(id, token string) (Status, error)
- func (m *Manager) Claim(ctx context.Context, id, token string, direction Direction) (*Lease, error)
- func (m *Manager) Cleaned(id string) error
- func (m *Manager) Close() error
- func (m *Manager) Lookup(scope, id string) (Status, error)
- func (m *Manager) Prepare(spec Spec, operationID string) (Prepared, error)
- func (m *Manager) Record(id string) (Record, error)
- func (m *Manager) Records() []Record
- func (m *Manager) Retry(scope, requestID, requestDigest string) (Prepared, bool, error)
- func (m *Manager) Shutdown(ctx context.Context) error
- func (m *Manager) Warn(id, warning string) error
- type Prepared
- type Record
- type Spec
- type State
- type Status
- type Store
Constants ¶
This section is empty.
Variables ¶
var ( ErrBusy = errors.New("transfer capacity unavailable") ErrConflict = errors.New("transfer conflicts with existing task") ErrNotFound = errors.New("transfer not found") ErrExpired = errors.New("transfer start window expired") ErrClosed = errors.New("transfer manager closed") ErrInvalidState = errors.New("transfer state does not permit this operation") ErrStoreLocked = errors.New("transfer metadata is already in use") ErrStoreUnusable = errors.New("transfer metadata cannot be persisted") )
Functions ¶
This section is empty.
Types ¶
type Journal ¶
type Journal struct {
// contains filtered or unexported fields
}
Journal serializes durable task snapshots under a permanent process lock. A failed Save may already have replaced a file; callers must fail closed rather than infer that an error means no persistent change occurred.
func OpenJournal ¶
type Lease ¶
type Lease struct {
// contains filtered or unexported fields
}
Lease owns a single data request. Call Close on every path, including error paths. No background worker is started: the HTTP handler performs the stream.
func (*Lease) BeginCommit ¶
BeginCommit durably records intent before returning a separate bounded context. Client disconnects after this boundary cannot cancel remote commit.
func (*Lease) ConfirmTemporary ¶
ConfirmTemporary runs immediately after a successful exclusive open and before writing content. Lost open replies leave ownership unconfirmed.
func (*Lease) Fail ¶
Fail classifies uncertain commits conservatively. It does not remove any remote file; cleanup uses a separate connection and this task's owned path.
func (*Lease) RejectCommit ¶
RejectCommit is reserved for a caller with evidence that rename was never attempted or was explicitly rejected by the remote SFTP server. Transport failure without that evidence must use Fail, producing Unknown instead.
type Limits ¶
type Limits struct {
MaxFileBytes int64
MaxActive int
MaxPerTarget int
MaxReady int
MaxRecords int
StartWindow time.Duration
Retention time.Duration
TotalTimeout time.Duration
CommitTimeout time.Duration
}
func DefaultLimits ¶
func DefaultLimits() Limits
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
NewManager takes ownership of store even if recovery fails. Recovery never resumes a stream or commits a remote file; it only classifies durable intent.
func (*Manager) Authenticate ¶
Authenticate deliberately returns the same error for an unknown task and a bad credential. Lookup for MCP management is separately scoped by service auth.
func (*Manager) CancelWithToken ¶
func (*Manager) Cleaned ¶
Cleaned records confirmed temporary-file removal or a failed exclusive creation that produced no owned file. Never use it to resolve unknown commit.
func (*Manager) Prepare ¶
Prepare returns the same task for an identical request. A still-ready task receives a new credential, revoking the previous one without extending TTL.
func (*Manager) Records ¶
Records provides an immutable snapshot for local recovery and owned-file cleanup. It is not a client status response and contains credential digests.
func (*Manager) Retry ¶
Retry returns an already-authorized task without opening the remote target or approving it again. Exact client input is compared before credential reissue.
type Record ¶
type Record struct {
Version int `json:"version"`
ID string `json:"id"`
OperationID string `json:"operationID"`
Spec Spec `json:"spec"`
TokenDigest string `json:"tokenDigest"`
State State `json:"state"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
StartBefore time.Time `json:"startBefore"`
StatusExpiresAt time.Time `json:"statusExpiresAt"`
TempPath string `json:"tempPath,omitempty"`
TempOwned bool `json:"tempOwned"`
Bytes int64 `json:"bytes"`
SHA256 string `json:"sha256,omitempty"`
Error string `json:"error,omitempty"`
Warning string `json:"warning,omitempty"`
CleanupPending bool `json:"cleanupPending"`
CancelRequested bool `json:"cancelRequested"`
Resolved bool `json:"resolved"`
Resolution string `json:"resolution,omitempty"`
}
Record is private journal data, not an HTTP response. TokenDigest must never be exposed by tool output or status responses.
type Spec ¶
type Spec struct {
RequestID string `json:"requestID"`
RequestDigest string `json:"requestDigest,omitempty"`
RequestedPath string `json:"requestedPath,omitempty"`
Scope string `json:"scope"`
Direction Direction `json:"direction"`
NodeID string `json:"nodeID"`
TargetID string `json:"targetID"`
RemotePath string `json:"remotePath"`
Size int64 `json:"size"`
SHA256 string `json:"sha256,omitempty"`
Overwrite bool `json:"overwrite"`
SourceModTime int64 `json:"sourceModTime,omitempty"`
}
Spec is the immutable, approved operation. TargetID identifies the resolved SSH target and account, including aliases that share a destination lock.
type Status ¶
type Status struct {
ID string `json:"transferID"`
OperationID string `json:"operationID"`
Direction Direction `json:"direction"`
NodeID string `json:"nodeID"`
RemotePath string `json:"remotePath"`
State State `json:"state"`
Size int64 `json:"size"`
Bytes int64 `json:"bytes"`
SHA256 string `json:"sha256,omitempty"`
Error string `json:"error,omitempty"`
Warning string `json:"warning,omitempty"`
CleanupPending bool `json:"cleanupPending"`
TempOwned bool `json:"temporaryOwnershipConfirmed"`
CancelRequested bool `json:"cancelRequested"`
Resolved bool `json:"resolved"`
StartBefore time.Time `json:"startBefore"`
StatusExpiresAt time.Time `json:"statusExpiresAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
Status deliberately excludes authentication scope and credential digests.