uploads

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: Apache-2.0, MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Worker

func Worker(ctx context.Context, in <-chan struct{}, doWork func() error, finalize func() error) error

Types

type API

type API struct {
	Repo                       Repo
	ExecuteScan                ExecuteScanFunc
	ExecuteDagScansForUpload   ExecuteDagScansForUploadFunc
	AddShardsForUpload         AddShardsForUploadFunc
	PostProcessUploadedShards  PostProcessUploadedShardsFunc
	PostProcessUploadedIndexes PostProcessUploadedIndexesFunc
	AddIndexesForUpload        AddIndexesForUploadFunc
	AddStorachaUploadForUpload AddStorachaUploadForUploadFunc
	RemoveBadFSEntry           RemoveBadFSEntryFunc
	RemoveBadNodes             RemoveBadNodesFunc
	RemoveShard                RemoveShardFunc

	// AddNodesToUploadShards assigns all unsharded nodes for an upload to shards.
	AddNodesToUploadShards AddNodesToUploadShardsFunc

	// AddShardsToUploadIndexes adds the contents of shards to the upload's indexes, creating new
	// indexes if necessary. If an index is closed as a result, the provided
	// `indexCB` callback is called with the closed index. `indexCB` may be nil.
	AddShardsToUploadIndexes AddShardsToUploadIndexesFunc

	// CloseUploadShards closes any remaining open shard for the upload.
	CloseUploadShards CloseUploadShardsFunc

	// CloseUploadIndexes closes any remaining open index for the upload.
	CloseUploadIndexes CloseUploadIndexesFunc

	// Publishes events observation
	Publisher bus.Publisher

	// AssumeUnchangedSources skips the filesystem scan when a completed scan
	// already exists, assuming the filesystem hasn't changed since the last run.
	AssumeUnchangedSources bool
}

func (API) ExecuteUpload

func (a API) ExecuteUpload(ctx context.Context, uploadID id.UploadID, spaceDID did.DID) (cid.Cid, error)

ExecuteUpload executes the upload process for a given upload, handling its state transitions and processing steps.

func (API) FindOrCreateUploads

func (a API) FindOrCreateUploads(ctx context.Context, spaceDID did.DID) ([]*model.Upload, error)

FindOrCreateUploads creates uploads for a given space and its associated sources.

func (API) GetUploadByID

func (a API) GetUploadByID(ctx context.Context, uploadID id.UploadID) (*model.Upload, error)

GetUploadByID retrieves an upload by its unique ID.

type AddIndexesForUploadFunc

type AddIndexesForUploadFunc func(ctx context.Context, uploadID id.UploadID, spaceDID did.DID, indexCB func(index *blobsmodel.Index) error) error

type AddNodeToUploadShardsFunc

type AddNodeToUploadShardsFunc func(ctx context.Context, uploadID id.UploadID, spaceDID did.DID, nodeCID cid.Cid, data []byte, shardCB func(shard *blobsmodel.Shard) error) error

type AddNodesToUploadShardsFunc added in v0.4.0

type AddNodesToUploadShardsFunc func(ctx context.Context, uploadID id.UploadID, spaceDID did.DID, shardCB func(shard *blobsmodel.Shard) error) error

type AddShardsForUploadFunc

type AddShardsForUploadFunc func(ctx context.Context, uploadID id.UploadID, spaceDID did.DID, shardCB func(shard *blobsmodel.Shard) error) error

type AddShardsToUploadIndexesFunc added in v0.4.0

type AddShardsToUploadIndexesFunc func(ctx context.Context, uploadID id.UploadID, indexCB func(index *blobsmodel.Index) error) error

type AddStorachaUploadForUploadFunc

type AddStorachaUploadForUploadFunc func(ctx context.Context, uploadID id.UploadID, spaceDID did.DID) error

type CloseUploadIndexesFunc added in v0.4.0

type CloseUploadIndexesFunc func(ctx context.Context, uploadID id.UploadID, indexCB func(index *blobsmodel.Index) error) error

type CloseUploadShardsFunc

type CloseUploadShardsFunc func(ctx context.Context, uploadID id.UploadID, shardCB func(shard *blobsmodel.Shard) error) error

type ExecuteDagScansForUploadFunc

type ExecuteDagScansForUploadFunc func(ctx context.Context, uploadID id.UploadID, nodeCB func(node dagmodel.Node, data []byte) error) error

type ExecuteScanFunc

type ExecuteScanFunc func(ctx context.Context, uploadID id.UploadID, nodeCB func(node scanmodel.FSEntry) error) error

type PostProcessUploadedIndexesFunc added in v0.4.0

type PostProcessUploadedIndexesFunc func(ctx context.Context, uploadID id.UploadID, spaceDID did.DID) error

type PostProcessUploadedShardsFunc added in v0.4.0

type PostProcessUploadedShardsFunc func(ctx context.Context, uploadID id.UploadID, spaceDID did.DID) error

type RemoveBadFSEntryFunc

type RemoveBadFSEntryFunc func(ctx context.Context, spaceDID did.DID, fsEntryID id.FSEntryID) error

type RemoveBadNodesFunc

type RemoveBadNodesFunc func(ctx context.Context, spaceDID did.DID, nodeCIDs []cid.Cid) error

type RemoveShardFunc

type RemoveShardFunc func(ctx context.Context, shardID id.ShardID) error

type Repo

type Repo interface {
	// GetUploadByID retrieves an upload by its unique ID.
	GetUploadByID(ctx context.Context, uploadID id.UploadID) (*uploadmodel.Upload, error)
	// FindOrCreateUploads ensures uploads exist for a given space
	FindOrCreateUploads(ctx context.Context, spaceDID did.DID, sourceIDs []id.SourceID) ([]*uploadmodel.Upload, error)
	// UpdateUpload updates the state of an upload in the repository.
	UpdateUpload(ctx context.Context, upload *uploadmodel.Upload) error
	// CIDForFSEntry retrieves the CID for a file system entry by its ID.
	CIDForFSEntry(ctx context.Context, fsEntryID id.FSEntryID) (cid.Cid, error)
	// CreateDAGScan creates a new DAG scan for a file system entry.
	CreateDAGScan(ctx context.Context, fsEntryID id.FSEntryID, isDirectory bool, uploadID id.UploadID, spaceDID did.DID) (dagmodel.DAGScan, error)
	// ListSpaceSources lists all space sources for the given space DID.
	ListSpaceSources(ctx context.Context, spaceDID did.DID) ([]id.SourceID, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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