Documentation ¶
Index ¶
- Constants
- Variables
- func WithStorageOption(opt *config.StorageOption) func(*storageManager) error
- type CommonTaskRequest
- type GCCallback
- type Manager
- type PeerTaskMetaData
- type PieceMetaData
- type ReadPieceRequest
- type Reclaimer
- type RegisterTaskRequest
- type ReusePeerTask
- type StoreRequest
- type TaskStorageDriver
- type UpdateTaskRequest
- type WritePieceRequest
Constants ¶
View Source
const (
GCName = "StorageManager"
)
Variables ¶
View Source
var ( ErrTaskNotFound = errors.New("task not found") ErrPieceNotFound = errors.New("piece not found") )
View Source
var (
ErrShortRead = errors.New("short read")
)
Functions ¶
func WithStorageOption ¶
func WithStorageOption(opt *config.StorageOption) func(*storageManager) error
Types ¶
type CommonTaskRequest ¶
type GCCallback ¶
type GCCallback func(request CommonTaskRequest)
type Manager ¶
type Manager interface { TaskStorageDriver // KeepAlive tests if storage is used in given time duration clientutil.KeepAlive // RegisterTask registers a task in storage driver RegisterTask(ctx context.Context, req RegisterTaskRequest) error // FindCompletedTask try to find a completed task for fast path FindCompletedTask(taskID string) *ReusePeerTask // CleanUp cleans all storage data CleanUp() }
func NewStorageManager ¶
func NewStorageManager(storeStrategy config.StoreStrategy, opt *config.StorageOption, gcCallback GCCallback, moreOpts ...func(*storageManager) error) (Manager, error)
type PeerTaskMetaData ¶
type PieceMetaData ¶
type PieceMetaData struct { Num int32 `json:"num,omitempty"` Md5 string `json:"md5,omitempty"` Offset uint64 `json:"offset,omitempty"` Range clientutil.Range `json:"range,omitempty"` Style base.PieceStyle `json:"style,omitempty"` }
type ReadPieceRequest ¶
type ReadPieceRequest struct { PeerTaskMetaData PieceMetaData }
type Reclaimer ¶
type Reclaimer interface { // CanReclaim indicates whether the storage can be reclaimed CanReclaim() bool // MarkReclaim marks the storage which will be reclaimed MarkReclaim() // Reclaim reclaims the storage Reclaim() error }
Reclaimer stands storage reclaimer
type RegisterTaskRequest ¶
type RegisterTaskRequest struct { CommonTaskRequest ContentLength int64 TotalPieces int32 }
type ReusePeerTask ¶
type ReusePeerTask = UpdateTaskRequest
type StoreRequest ¶
type StoreRequest struct { CommonTaskRequest MetadataOnly bool StoreOnly bool TotalPieces int32 }
type TaskStorageDriver ¶
type TaskStorageDriver interface { // WritePiece put a piece of a task to storage WritePiece(ctx context.Context, req *WritePieceRequest) (int64, error) // ReadPiece get a piece data reader of a task from storage // return a Reader and a Closer from task data with seeked, caller should read bytes and close it. // If req.Num is equal to -1, range has a fixed value. ReadPiece(ctx context.Context, req *ReadPieceRequest) (io.Reader, io.Closer, error) ReadAllPieces(ctx context.Context, req *PeerTaskMetaData) (io.ReadCloser, error) GetPieces(ctx context.Context, req *base.PieceTaskRequest) (*base.PiecePacket, error) UpdateTask(ctx context.Context, req *UpdateTaskRequest) error // Store stores task data to the target path Store(ctx context.Context, req *StoreRequest) error }
type UpdateTaskRequest ¶
type UpdateTaskRequest struct { PeerTaskMetaData ContentLength int64 TotalPieces int32 }
type WritePieceRequest ¶
type WritePieceRequest struct { PeerTaskMetaData PieceMetaData UnknownLength bool Reader io.Reader }
Click to show internal directories.
Click to hide internal directories.