transfers

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessFailure added in v0.4.2

type AccessFailure struct {
	ObjectID string
	Err      error
}

type AccessLookupRequest added in v0.4.2

type AccessLookupRequest struct {
	ObjectID string
	AccessID string
}

type AccessLookupResult

type AccessLookupResult struct {
	Found  bool
	URL    string
	Target storage.Target
	Object *drs.DrsObject
}

type AccessRequest

type AccessRequest struct {
	Object *drs.DrsObject
	Target storage.Target
	// Scope is an operation-selected attribution scope. It is optional because
	// most transfer paths do not select a project independently of the object.
	// RecordAccessIssued validates it against the object's canonical resources
	// before using it for event attribution.
	Scope          *AccessScope
	AccessID       string
	Direction      string
	StorageURL     string
	RangeStart     *int64
	RangeEnd       *int64
	BytesRequested int64
	ClientName     string
	ClientVersion  string
}

AccessRequest is the transfer-domain request for one access-issued event. Object is already authorized and hydrated by the caller; transfers does not perform another object lookup.

type AccessScope

type AccessScope struct {
	Organization string
	Project      string
}

AccessScope identifies the organization/project scope selected by an already-authorized transfer operation.

type AccountingMode added in v0.4.2

type AccountingMode string
const (
	AccountingNone                AccountingMode = "none"
	AccountingDownloadBeforeEvent AccountingMode = "download_before_event"
	AccountingEventOnly           AccountingMode = "event_only"
)

type BulkAccessLookupResult

type BulkAccessLookupResult struct {
	Requested int
	Resolved  []ResolvedAccess
	Failures  []AccessFailure
}

type ByteRange added in v0.4.2

type ByteRange struct {
	Start int64
	End   int64
}

ByteRange is the inclusive byte range requested by a transfer operation. Storage providers receive the translated storage.ByteRange only inside the transfer service boundary.

type CanonicalStorageTarget

type CanonicalStorageTarget struct {
	Bucket string
	Key    string
	URL    string
}

CanonicalStorageTarget is a provider-neutral target. URL is the canonical s3:// representation for bucket/key targets; non-S3 locations are returned with only URL populated by ResolveCanonicalStorageTarget.

type CanonicalStorageTargetRequest

type CanonicalStorageTargetRequest struct {
	Object         *drs.DrsObject
	AccessURL      string
	Bucket         string
	Key            string
	PreferChecksum bool
}

CanonicalStorageTargetRequest describes the object-backed target selection used by upload signing and by repairable logical download URLs.

type CompletedPart added in v0.4.2

type CompletedPart struct {
	ETag       string
	PartNumber int32
}

CompletedPart carries multipart completion metadata across the transfer boundary. Provider-specific part values are created only by Service.

type CredentialReader

type CredentialReader interface {
	ListS3Credentials(context.Context) ([]buckets.Credential, error)
}

type Dependencies

type Dependencies struct {
	Objects              ObjectPort
	Storage              StoragePort
	FileCounters         usage.FileCounterRecorder
	Scopes               ScopeReader
	Credentials          CredentialReader
	Events               EventRecorder
	MultipartSessions    MultipartSessionStore
	Now                  func() time.Time
	DefaultSigningExpiry time.Duration
}

type DownloadRequest added in v0.4.2

type DownloadRequest struct {
	ObjectID   string
	AccessID   string
	ExpiresIn  time.Duration
	Range      *ByteRange
	Accounting AccountingMode
}

type DownloadResult added in v0.4.2

type DownloadResult struct {
	URL       string
	SourceURL string
	Target    storage.Target
	Object    *drs.DrsObject
}

type EventRecorder

type EventRecorder interface {
	RecordTransferAttributionEvents(context.Context, []usage.Event) error
}

type MultipartAbortStore added in v0.4.2

type MultipartAbortStore interface {
	ClaimMultipartAbort(context.Context, string, string, time.Time, time.Time) (MultipartSession, bool, error)
	FinishMultipartAbort(context.Context, string, string, time.Time) (bool, error)
}

type MultipartAborter added in v0.4.2

type MultipartAborter interface {
	AbortMultipart(context.Context, storage.AbortMultipartRequest) error
}

type MultipartActivityStore added in v0.4.2

type MultipartActivityStore interface {
	TouchMultipartSession(context.Context, string, time.Time) error
}

type MultipartAuthorization added in v0.4.2

type MultipartAuthorization struct {
	Resources []string     `json:"resources,omitempty"`
	Methods   []string     `json:"methods,omitempty"`
	Scope     *AccessScope `json:"scope,omitempty"`
}

func (MultipartAuthorization) Authorize added in v0.4.2

func (a MultipartAuthorization) Authorize(ctx context.Context) error

type MultipartCompletionPartsClaimer added in v0.4.2

type MultipartCompletionPartsClaimer interface {
	ClaimMultipartCompletionWithParts(context.Context, string, string, string, []CompletedPart, time.Time, time.Time) (MultipartSession, bool, error)
}

Optional multipart capabilities preserve compatibility for callers with lightweight session stores while the durable store can persist operation intent and completion inputs atomically.

type MultipartCompletionReceipt added in v0.4.2

type MultipartCompletionReceipt struct {
	UploadID          string
	Authorization     MultipartAuthorization
	PartsFingerprint  string
	CompletedLocation string
}

type MultipartCompletionReceiptStore added in v0.4.2

type MultipartCompletionReceiptStore interface {
	GetMultipartCompletionReceipt(context.Context, string) (MultipartCompletionReceipt, error)
}

type MultipartInitRequest added in v0.4.2

type MultipartInitRequest struct {
	GUID          *string
	Key           *string
	Organization  *string
	Project       *string
	Target        *storage.Target
	Authorization *MultipartAuthorization
}

type MultipartInitResult added in v0.4.2

type MultipartInitResult struct {
	UploadID string
	GUID     string
}

type MultipartOperation added in v0.4.2

type MultipartOperation string
const (
	MultipartOperationNone     MultipartOperation = ""
	MultipartOperationComplete MultipartOperation = "complete"
	MultipartOperationAbort    MultipartOperation = "abort"
)

type MultipartReconcilerStore added in v0.4.2

type MultipartReconcilerStore interface {
	ListMultipartSessionsForReconcile(context.Context, time.Time, time.Time, int) ([]MultipartSession, error)
	CompactCompletedMultipartSessions(context.Context, time.Time, int) error
}

type MultipartSession added in v0.4.2

type MultipartSession struct {
	UploadID          string                 `json:"upload_id"`
	CompletionID      string                 `json:"completion_id"`
	Target            storage.Target         `json:"target"`
	Authorization     MultipartAuthorization `json:"authorization"`
	State             MultipartState         `json:"state"`
	CompletionToken   string                 `json:"completion_token,omitempty"`
	PartsFingerprint  string                 `json:"parts_fingerprint,omitempty"`
	Operation         MultipartOperation     `json:"operation,omitempty"`
	CompletionParts   []CompletedPart        `json:"completion_parts,omitempty"`
	CompletedLocation string                 `json:"completed_location,omitempty"`
	CreatedAt         time.Time              `json:"created_at"`
	UpdatedAt         time.Time              `json:"updated_at"`
}

type MultipartSessionStore added in v0.4.2

type MultipartSessionStore interface {
	SaveMultipartSession(context.Context, MultipartSession) error
	GetMultipartSession(context.Context, string) (MultipartSession, error)
	ClaimMultipartCompletion(context.Context, string, string, string, time.Time, time.Time) (MultipartSession, bool, error)
	ReleaseMultipartCompletion(context.Context, string, string, time.Time) error
	FinishMultipartCompletion(context.Context, string, string, string, time.Time) (bool, error)
}

type MultipartState added in v0.4.2

type MultipartState string
const (
	MultipartStateActive     MultipartState = "active"
	MultipartStateCompleting MultipartState = "completing"
	MultipartStateCompleted  MultipartState = "completed"
)

type ObjectPort added in v0.4.2

type ObjectPort interface {
	GetObject(context.Context, string, string) (*drs.DrsObject, error)
	GetObjectsByChecksums(context.Context, []string, string) (map[string][]drs.DrsObject, error)
}

ObjectPort is the catalog capability required by transfer operations.

type ResolvedAccess

type ResolvedAccess struct {
	ObjectID string
	AccessID string
	URL      string
}

type ScopeReader

type ScopeReader interface {
	LookupBucketScope(context.Context, string, string) (buckets.Scope, bool, error)
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(deps Dependencies) *Service

func (*Service) AbortMultipart added in v0.4.2

func (s *Service) AbortMultipart(ctx context.Context, uploadID string) error

AbortMultipart is an additive, idempotent operation. Authorization is evaluated before a durable abort lease is claimed, while the provider call itself runs under the claimed session state.

func (*Service) BeginMultipart added in v0.4.2

func (s *Service) BeginMultipart(ctx context.Context, req MultipartInitRequest) (MultipartInitResult, error)

func (*Service) CompleteMultipart added in v0.4.2

func (s *Service) CompleteMultipart(ctx context.Context, uploadID string, parts []CompletedPart) (string, error)

func (*Service) Download added in v0.4.2

func (s *Service) Download(ctx context.Context, req DownloadRequest) (DownloadResult, error)

func (*Service) IssueAccess added in v0.4.2

func (s *Service) IssueAccess(ctx context.Context, request AccessLookupRequest) (AccessLookupResult, error)

func (*Service) IssueAccessBulk added in v0.4.2

func (s *Service) IssueAccessBulk(ctx context.Context, requests []AccessLookupRequest) BulkAccessLookupResult

func (*Service) ReconcileMultipartSessions added in v0.4.2

func (s *Service) ReconcileMultipartSessions(ctx context.Context, inactiveTimeout, completedRetention time.Duration, batchSize int) error

func (*Service) RecordAccessIssued

func (s *Service) RecordAccessIssued(ctx context.Context, request AccessRequest) error

RecordAccessIssued assembles one usage event and sends it to the narrow recorder. A nil object remains a no-op for new-object upload paths.

func (*Service) ResolveCanonicalStorageTarget

func (s *Service) ResolveCanonicalStorageTarget(ctx context.Context, req CanonicalStorageTargetRequest) (CanonicalStorageTarget, error)

ResolveCanonicalStorageTarget selects the physical target for an object. Scoped objects use the last non-empty bucket from their deterministic scope order and compose nested path prefixes. Unscoped non-S3 URLs pass through.

func (*Service) ResolveScopedUploadTarget

func (s *Service) ResolveScopedUploadTarget(ctx context.Context, organization, project, key string) (CanonicalStorageTarget, error)

ResolveScopedUploadTarget resolves an upload resource into its physical bucket/key. Organization and project scopes compose in lookup order.

func (*Service) SignMultipartPart

func (s *Service) SignMultipartPart(ctx context.Context, uploadID string, partNumber int32) (string, error)

func (*Service) UploadBulk added in v0.4.2

func (s *Service) UploadBulk(ctx context.Context, requests []UploadRequest) []UploadResult

func (*Service) UploadURL added in v0.4.2

func (s *Service) UploadURL(ctx context.Context, req UploadRequest) (UploadResult, error)

type StoragePort added in v0.4.2

StoragePort is the provider-neutral storage capability required by transfer operations. Target selection and credential binding stay below this boundary.

type UploadRequest added in v0.4.2

type UploadRequest struct {
	ObjectID  string
	Key       string
	Scope     *AccessScope
	ExpiresIn time.Duration
}

type UploadResult added in v0.4.2

type UploadResult struct {
	URL      string
	Target   storage.Target
	Existing bool
	ObjectID string
	Err      error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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