asset

package
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 52 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateCid added in v0.1.13

func CalculateCid(r io.Reader) (cid.Cid, error)

CalculateCid calculates the CID for the given reader.

Types

type AWS added in v0.1.13

type AWS interface {
	// PullAssetWithURL download the file locally from the url and save it as car file
	PullAssetFromAWS(ctx context.Context, bucket, key string) error
}

func NewAWS added in v0.1.13

func NewAWS(scheduler api.Scheduler, storage storage.Storage) AWS

type Asset

type Asset struct {
	TotalBlockCount int

	AWS
	// contains filtered or unexported fields
}

func NewAsset

func NewAsset(storageMgr *storage.Manager, scheduler api.Scheduler, assetMgr *Manager, apiSecret *jwt.HMACSHA) *Asset

NewAsset creates a new Asset instance

func (*Asset) AddAssetView added in v0.1.15

func (a *Asset) AddAssetView(ctx context.Context, assetCIDs []string) error

func (*Asset) BlockCountOfAsset

func (a *Asset) BlockCountOfAsset(assetCID string) (int, error)

BlockCountOfAsset returns the block count for the given asset.

func (*Asset) CreateAsset added in v0.1.10

func (a *Asset) CreateAsset(ctx context.Context, tokenPayload *types.AuthUserUploadDownloadAsset) (string, error)

CreateAsset notify candidate that user upload asset, return auth token of candidate

func (*Asset) DeleteAsset

func (a *Asset) DeleteAsset(ctx context.Context, assetCID string) error

DeleteAsset deletes the asset with the given CID

func (*Asset) GetAssetProgresses

func (a *Asset) GetAssetProgresses(ctx context.Context, assetCIDs []string) (*types.PullResult, error)

GetAssetProgresses returns the progress of the given list of assets.

func (*Asset) GetAssetStats

func (a *Asset) GetAssetStats(ctx context.Context) (*types.AssetStats, error)

GetAssetStats returns statistics about the assets stored on this node

func (*Asset) GetAssetView added in v0.1.14

func (a *Asset) GetAssetView(ctx context.Context) (*types.AssetView, error)

func (*Asset) GetAssetsInBucket added in v0.1.14

func (a *Asset) GetAssetsInBucket(ctx context.Context, bucketID int) ([]string, error)

func (*Asset) GetBlocksOfAsset

func (a *Asset) GetBlocksOfAsset(assetCID string, randomSeed int64, randomCount int) ([]string, error)

GetBlocksOfAsset returns a random subset of blocks for the given asset.

func (*Asset) GetPullingAssetInfo

func (a *Asset) GetPullingAssetInfo(ctx context.Context) (*types.InProgressAsset, error)

GetPullingAssetInfo returns information about the asset currently being pulled

func (*Asset) PullAsset

func (a *Asset) PullAsset(ctx context.Context, rootCID string, infos []*types.CandidateDownloadInfo) error

PullAsset adds the asset to the waitList for pulling

func (*Asset) SyncAssetViewAndData added in v0.1.16

func (a *Asset) SyncAssetViewAndData(ctx context.Context) error

type AssetPullerEncoder

type AssetPullerEncoder struct {
	Root                    string
	BlocksWaitList          []string
	BlocksPulledSuccessList []string
	NextLayerCIDs           []string
	DownloadSources         []*types.CandidateDownloadInfo
	TotalSize               uint64
	DoneSize                uint64
}

AssetPullerEncoder encodes or decodes assetPuller

type CarStream added in v0.1.13

type CarStream interface {
	io.ReadWriter
	io.ReaderAt
	io.WriterAt
	io.Seeker
}

CarStream is an interface that combines io.ReadWriter, io.ReaderAt, io.WriterAt, io.Seeker.

type Key

type Key string

type Manager

type Manager struct {
	storage.Storage
	api.Scheduler
	// contains filtered or unexported fields
}

Manager is the struct that manages asset pulling and store

func NewManager

func NewManager(opts *ManagerOptions) (*Manager, error)

NewManager creates a new instance of Manager

func (*Manager) AddLostAsset

func (m *Manager) AddLostAsset(root cid.Cid) error

AddLostAsset adds a lost asset to the Manager's waitList if it is not already present in the storage

func (*Manager) DeleteAsset

func (m *Manager) DeleteAsset(root cid.Cid) error

DeleteAsset removes an asset from the datastore and the waitList.

func (*Manager) GetAssetForValidation

func (m *Manager) GetAssetForValidation(ctx context.Context, randomSeed int64) (validate.Asset, error)

GetAssetForValidation returns a new instance of asset based on a given random seed

func (*Manager) GetAssetsOfBucket

func (m *Manager) GetAssetsOfBucket(ctx context.Context, bucketID uint32, isRemote bool) ([]cid.Cid, error)

GetAssetsOfBucket retrieves the list of assets in a given bucket ID from the storage

func (*Manager) GetBlock

func (m *Manager) GetBlock(ctx context.Context, root, block cid.Cid) (blocks.Block, error)

GetBlock returns the block with the given CID from the LRU cache

func (*Manager) GetBlockCount added in v0.1.10

func (m *Manager) GetBlockCount(ctx context.Context, root cid.Cid) (int, error)

func (*Manager) GetBlocksOfAsset

func (m *Manager) GetBlocksOfAsset(root cid.Cid, randomSeed int64, randomCount int) ([]string, error)

GetBlocksOfAsset returns a random selection of blocks for the given root CID return map, key is random number, value is cid string

func (*Manager) GetUploadingAsset added in v0.1.10

func (m *Manager) GetUploadingAsset(ctx context.Context, root cid.Cid) (*types.UploadingAsset, error)

func (*Manager) HasBlock

func (m *Manager) HasBlock(ctx context.Context, root, block cid.Cid) (bool, error)

HasBlock checks if a block with the given CID exists in the LRU cache

func (*Manager) SaveUserAsset added in v0.1.10

func (m *Manager) SaveUserAsset(ctx context.Context, userID string, root cid.Cid, assetSize int64, r io.Reader) error

func (*Manager) ScanBlocks

func (m *Manager) ScanBlocks(ctx context.Context, root cid.Cid) error

func (*Manager) SetAssetUploadProgress added in v0.1.10

func (m *Manager) SetAssetUploadProgress(ctx context.Context, root cid.Cid, progress *types.UploadProgress) error

type ManagerOptions

type ManagerOptions struct {
	Storage      storage.Storage
	IPFSAPIURL   string
	SchedulerAPI api.Scheduler
	PullParallel int
	PullTimeout  int
	PullRetry    int
}

ManagerOptions is the struct that contains options for Manager

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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