module

package
v0.2.1-test-5 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

README

Modular

Modular is a complete logical module of SP. The GfSp framework is responsible for the necessary interaction between modules. As for the implementation of the module, it can be customized. Example, The GfSp framework stipulates that ask object approval must be carried out before uploading an object, whether agrees the approval, SP can be customized.

Concept

Front Modular

Front Modular handles the user's request, the gater will generate corresponding task and send to Front Modular, the Front Modular need check the request is correct. and after handle the task maybe some extra work is required. So the Front Modular has three interfaces for each task type, PreHandleXXXTask, HandleXXXTask andPostHandleXXXTask. Front Modular includes: Approver, Downloader and Uploader.

Background Modular

Background Modular handles the SP inner task, since it is internally generated, the correctness of the information can be guaranteed, so only have one interfaceHandleXXXTask. Background Modular includes: Authorizer, TaskExecutor,Manager, P2P, c and Signer.

Modular Type

The GfSp framework specifies the following modular: Gater, Approver, Authorizer, Uploader, Downloader, Manager, P2P, Receiver, Signerand Metadata. The GfSp framework also supports extending more customized mudolar as needed. As long as it is registered in GfSp framework and executes the modular interface, it will be initialized and scheduled.

Gater

Gater as SP's gateway, provides http service and follows the s3 protocol, and generates corresponding task and forwards them to other modular in the SP. It does not allow customization, so no interface is defined in the modular file.

Approver

Approver is the modular to handle ask approval request, handles CreateBucketApproval and CreateObjectApproval.

Authorizer

Authorizer is the modular to authority verification.

Downloader

Downloader is the modular to handle get object request from user account, and get challenge info request from other components in the system.

TaskExecutor

TaskExecutor is the modular to handle background task, it will ask task from Manager modular, handle the task and report the result or status to the manager modular includes: ReplicatePieceTask, SealObjectTask, ReceivePieceTask, GCObjectTask, GCZombiePieceTask, GCMetaTask.

Manager

Manager is the modular to SP's manage modular, it is Responsible for task scheduling and other management of SP.

P2P

P2P is the modular to the interaction of control information between Sps, handles the ask replicate piece approval, it will broadcast the approval to other SPs, wait the responses, if up to min approved number or max approved number before timeout, will return the approvals.

Receiver

Receiver is the modular to receive the piece data from primary SP, calculates the integrity hash of the piece data and sign it, returns to the primary SP for sealing object on greenfield.

Signer

Signer is the modular to handle the SP's sign and on greenfield chain operator. It holds SP all private key. Considering the sp account's sequence number, it must be a singleton.

Uploader

Uploader is the modular to handle put object request from user account, and store it in primary SP's piece store.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ApprovalModularName             = strings.ToLower("Approval")
	ApprovalModularDescription      = "Handles the ask crate bucket/object and replicate piece approval request."
	AuthorizationModularName        = strings.ToLower("Authorizer")
	AuthorizationModularDescription = "Authorization authentication."
	DownloadModularName             = strings.ToLower("Downloader")
	DownloadModularDescription      = "Downloads object and get challenge info from the backend and statistical read traffic."
	ExecuteModularName              = strings.ToLower("TaskExecutor")
	ExecuteModularDescription       = "Executes background task."
	GateModularName                 = strings.ToLower("Gateway")
	GateModularDescription          = "Receives the user request and route to the responding service."
	ManageModularName               = strings.ToLower("Manager")
	ManageModularDescription        = "SP management and task scheduling."
	P2PModularName                  = strings.ToLower("p2p")
	P2PModularDescription           = "Communicates between SPs on p2p protocol."
	ReceiveModularName              = strings.ToLower("Receiver")
	ReceiveModularDescription       = "Receives data pieces of an object from other storage provider and store."
	SignerModularName               = strings.ToLower("Signer")
	SignerModularDescription        = "Sign the transaction and broadcast to chain"
	UploadModularName               = strings.ToLower("Uploader")
	UploadModularDescription        = "Uploads object payload to primary SP"
)
View Source
var (
	ErrNilModular = errors.New("call nil module, please check again")
)

Functions

This section is empty.

Types

type Approver

type Approver interface {
	Modular
	// PreCreateBucketApproval prepares to handle CreateBucketApproval, it can do some
	// checks Example: check for duplicates, if limit specified by SP is reached, etc.
	PreCreateBucketApproval(ctx context.Context, task task.ApprovalCreateBucketTask) error
	// HandleCreateBucketApprovalTask handles the CreateBucketApproval, set expired
	// height and sign the MsgCreateBucket etc.
	HandleCreateBucketApprovalTask(ctx context.Context, task task.ApprovalCreateBucketTask) (bool, error)
	// PostCreateBucketApproval is called after HandleCreateBucketApprovalTask, it can
	// recycle resources, statistics and other operations.
	PostCreateBucketApproval(ctx context.Context, task task.ApprovalCreateBucketTask)

	// PreCreateObjectApproval prepares to handle CreateObjectApproval, it can do some
	// checks Example: check for duplicates, if limit specified by SP is reached, etc.
	PreCreateObjectApproval(ctx context.Context, task task.ApprovalCreateObjectTask) error
	// HandleCreateObjectApprovalTask handles the MsgCreateObject, set expired height
	// and sign the MsgCreateBucket etc.
	HandleCreateObjectApprovalTask(ctx context.Context, task task.ApprovalCreateObjectTask) (bool, error)
	// PostCreateObjectApproval is called after HandleCreateObjectApprovalTask, it can
	// recycle resources, statistics and other operations.
	PostCreateObjectApproval(ctx context.Context, task task.ApprovalCreateObjectTask)
	// QueryTasks queries tasks that running on approver by task sub key.
	QueryTasks(ctx context.Context, subKey task.TKey) ([]task.Task, error)
}

Approver is the interface to handle ask approval.

type AuthOpType

type AuthOpType int32

AuthOpType defines the operator type used to authority verification.

const (
	// AuthOpTypeUnKnown defines the default value of AuthOpType
	AuthOpTypeUnKnown AuthOpType = iota
	// AuthOpAskCreateBucketApproval defines the AskCreateBucketApproval operator
	AuthOpAskCreateBucketApproval
	// AuthOpAskCreateObjectApproval defines the AskCreateObjectApproval operator
	AuthOpAskCreateObjectApproval
	// AuthOpTypeChallengePiece defines the ChallengePiece operator
	AuthOpTypeChallengePiece
	// AuthOpTypePutObject defines the PutObject operator
	AuthOpTypePutObject
	// AuthOpTypeGetObject defines the GetObject operator
	AuthOpTypeGetObject
	// AuthOpTypeGetUploadingState defines the GetUploadingState operator
	AuthOpTypeGetUploadingState
	// AuthOpTypeGetBucketQuota defines the GetBucketQuota operator
	AuthOpTypeGetBucketQuota
	// AuthOpTypeListBucketReadRecord defines the ListBucketReadRecord operator
	AuthOpTypeListBucketReadRecord
)

type Authorizer

type Authorizer interface {
	Modular
	// VerifyAuthorize verifies the operator authority.
	VerifyAuthorize(ctx context.Context, auth AuthOpType, account, bucket, object string) (bool, error)
}

Authorizer is the interface to authority verification modular.

type Downloader

type Downloader interface {
	Modular
	// PreDownloadObject prepares to handle DownloadObject, it can do some checks
	// Example: check for duplicates, if limit specified by SP is reached, etc.
	PreDownloadObject(ctx context.Context, task task.DownloadObjectTask) error
	// HandleDownloadObjectTask handles the DownloadObject, get data from piece store.
	HandleDownloadObjectTask(ctx context.Context, task task.DownloadObjectTask) ([]byte, error)
	// PostDownloadObject is called after HandleDownloadObjectTask, it can recycle
	// resources, statistics and other operations.
	PostDownloadObject(ctx context.Context, task task.DownloadObjectTask)

	// PreChallengePiece prepares to handle ChallengePiece, it can do some checks
	// Example: check for duplicates, if limit specified by SP is reached, etc.
	PreChallengePiece(ctx context.Context, task task.ChallengePieceTask) error
	// HandleChallengePiece handles the ChallengePiece, get piece data from piece
	// store and get integrity hash from db.
	HandleChallengePiece(ctx context.Context, task task.ChallengePieceTask) ([]byte, [][]byte, []byte, error)
	// PostChallengePiece is called after HandleChallengePiece, it can recycle
	// resources, statistics and other operations.
	PostChallengePiece(ctx context.Context, task task.ChallengePieceTask)
	// QueryTasks queries download/challenge tasks that running on downloader by
	// task sub key.
	QueryTasks(ctx context.Context, subKey task.TKey) ([]task.Task, error)
}

Downloader is the interface to handle get object request from user account, and get challenge info request from other components in the system.

type Manager

type Manager interface {
	Modular
	// DispatchTask dispatches the task to TaskExecutor modular when it ask task.
	// It will consider task remaining resources when dispatches task.
	DispatchTask(ctx context.Context, limit rcmgr.Limit) (task.Task, error)
	// QueryTasks queries tasks that hold on manager by task sub key.
	QueryTasks(ctx context.Context, subKey task.TKey) ([]task.Task, error)
	// HandleCreateUploadObjectTask handles the CreateUploadObject request from
	// Uploader, before Uploader handles the user's UploadObject request, it should
	// send CreateUploadObject request to Manager ask if it's ok. Through this
	// interface that SP implements the global upload object strategy.
	//
	// Example: control the concurrency of global uploads, avoid repeated uploads,
	// rate control, etc.
	HandleCreateUploadObjectTask(ctx context.Context, task task.UploadObjectTask) error
	// HandleDoneUploadObjectTask handles the result of uploading object payload
	// data to primary, Manager should generate ReplicatePieceTask for TaskExecutor
	// to run.
	HandleDoneUploadObjectTask(ctx context.Context, task task.UploadObjectTask) error
	// HandleReplicatePieceTask handles the result of replicating pieces data to
	// secondary SPs, the request comes from TaskExecutor.
	HandleReplicatePieceTask(ctx context.Context, task task.ReplicatePieceTask) error
	// HandleSealObjectTask handles the result of sealing object to the greenfield
	// the request comes from TaskExecutor.
	HandleSealObjectTask(ctx context.Context, task task.SealObjectTask) error
	// HandleReceivePieceTask handles the result of receiving piece task, the request
	// comes from Receiver that reports have completed the receive task to manager and
	// TaskExecutor that the result of confirming whether the object as secondary SP
	// has been sealed.
	HandleReceivePieceTask(ctx context.Context, task task.ReceivePieceTask) error
	// HandleGCObjectTask handles the result or status of GCObjectTask, the request
	// comes from TaskExecutor.
	HandleGCObjectTask(ctx context.Context, task task.GCObjectTask) error
	// HandleGCZombiePieceTask handles the result or status GCZombiePieceTask, the
	// request comes from TaskExecutor.
	HandleGCZombiePieceTask(ctx context.Context, task task.GCZombiePieceTask) error
	// HandleGCMetaTask handles the result or status GCMetaTask, the request comes
	// from TaskExecutor.
	HandleGCMetaTask(ctx context.Context, task task.GCMetaTask) error
	// HandleDownloadObjectTask handles the result DownloadObjectTask, the request comes
	// from Downloader.
	HandleDownloadObjectTask(ctx context.Context, task task.DownloadObjectTask) error
	// HandleChallengePieceTask handles the result ChallengePieceTask, the request comes
	// from Downloader.
	HandleChallengePieceTask(ctx context.Context, task task.ChallengePieceTask) error
}

Manager is the interface to SP's manage modular, it is Responsible for task scheduling and other management of SP.

type Modular

type Modular interface {
	lifecycle.Service
	// ReserveResource reserves the resources from Modular resources pool.
	ReserveResource(ctx context.Context, state *rcmgr.ScopeStat) (rcmgr.ResourceScopeSpan, error)
	// ReleaseResource releases the resources to Modular resources pool.
	ReleaseResource(ctx context.Context, scope rcmgr.ResourceScopeSpan)
}

Modular is the interface to submodule that units scheduled by the GfSp framework. the Modular inherits lifecycle.Service interface, used to managed by lifecycle. and it also is managed by ResourceManager, the GfSp framework will reserve and release resources from Modular resources pool.

type NilModular

type NilModular struct{}

func (*NilModular) AskTask

func (*NilModular) AskTask(context.Context, rcmgr.Limit)

func (*NilModular) HandleChallengePiece

func (*NilModular) HandleChallengePiece(context.Context, task.ChallengePieceTask) ([]byte, [][]byte, []byte, error)

func (*NilModular) HandleDownloadObjectTask

func (*NilModular) HandleDownloadObjectTask(context.Context, task.DownloadObjectTask) ([]byte, error)

func (*NilModular) HandleGCMetaTask

func (*NilModular) HandleGCMetaTask(context.Context, task.GCMetaTask)

func (*NilModular) HandleGCObjectTask

func (*NilModular) HandleGCObjectTask(context.Context, task.GCObjectTask)

func (*NilModular) HandleGCZombiePieceTask

func (*NilModular) HandleGCZombiePieceTask(context.Context, task.GCZombiePieceTask)

func (*NilModular) HandleQueryBootstrap

func (*NilModular) HandleQueryBootstrap(context.Context) ([]string, error)

func (*NilModular) HandleReceivePieceTask

func (*NilModular) HandleReceivePieceTask(context.Context, task.ReceivePieceTask)

func (*NilModular) HandleReplicatePieceTask

func (*NilModular) HandleReplicatePieceTask(context.Context, task.ReplicatePieceTask)

func (*NilModular) HandleSealObjectTask

func (*NilModular) HandleSealObjectTask(context.Context, task.SealObjectTask)

func (*NilModular) Name

func (*NilModular) Name() string

func (*NilModular) PostChallengePiece

func (*NilModular) PostChallengePiece(context.Context, task.ChallengePieceTask)

func (*NilModular) PostDownloadObject

func (*NilModular) PostDownloadObject(context.Context, task.DownloadObjectTask)

func (*NilModular) PreChallengePiece

func (*NilModular) PreChallengePiece(context.Context, task.ChallengePieceTask) error

func (*NilModular) PreDownloadObject

func (*NilModular) PreDownloadObject(context.Context, task.DownloadObjectTask) error

func (*NilModular) QueryTasks

func (*NilModular) QueryTasks(ctx context.Context, keyPrefix task.TKey) ([]task.Task, error)

func (*NilModular) ReleaseResource

func (*NilModular) ReleaseResource(context.Context, rcmgr.ResourceScopeSpan)

func (*NilModular) ReportTask

func (*NilModular) ReportTask(context.Context, task.Task) error

func (*NilModular) ReserveResource

func (*NilModular) SealObject

func (*NilModular) SignCreateBucketApproval

func (*NilModular) SignCreateBucketApproval(context.Context, *storagetypes.MsgCreateBucket) ([]byte, error)

func (*NilModular) SignCreateObjectApproval

func (*NilModular) SignCreateObjectApproval(context.Context, *storagetypes.MsgCreateObject) ([]byte, error)

func (*NilModular) SignIntegrityHash

func (*NilModular) SignIntegrityHash(ctx context.Context, objectID uint64, hash [][]byte) ([]byte, []byte, error)

func (*NilModular) SignP2PPingMsg

func (*NilModular) SignP2PPingMsg(context.Context, *gfspp2p.GfSpPing) ([]byte, error)

func (*NilModular) SignP2PPongMsg

func (*NilModular) SignP2PPongMsg(context.Context, *gfspp2p.GfSpPong) ([]byte, error)

func (*NilModular) SignReceivePieceTask

func (*NilModular) SignReceivePieceTask(context.Context, task.ReceivePieceTask) ([]byte, error)

func (*NilModular) SignReplicatePieceApproval

func (*NilModular) SignReplicatePieceApproval(context.Context, task.ApprovalReplicatePieceTask) ([]byte, error)

func (*NilModular) Start

func (*NilModular) Start(context.Context) error

func (*NilModular) Stop

type NullModular

type NullModular struct{}

func (*NullModular) DispatchTask

func (*NullModular) DispatchTask(context.Context, rcmgr.Limit) (task.Task, error)

func (*NullModular) HandleChallengePieceTask

func (*NullModular) HandleChallengePieceTask(context.Context, task.ChallengePieceTask) error

func (*NullModular) HandleCreateBucketApprovalTask

func (*NullModular) HandleCreateBucketApprovalTask(context.Context, task.ApprovalCreateBucketTask) (bool, error)

func (*NullModular) HandleCreateObjectApprovalTask

func (*NullModular) HandleCreateObjectApprovalTask(context.Context, task.ApprovalCreateObjectTask) (bool, error)

func (*NullModular) HandleCreateUploadObjectTask

func (*NullModular) HandleCreateUploadObjectTask(context.Context, task.UploadObjectTask) error

func (*NullModular) HandleDoneUploadObjectTask

func (*NullModular) HandleDoneUploadObjectTask(context.Context, task.UploadObjectTask) error

func (*NullModular) HandleDownloadObjectTask

func (*NullModular) HandleDownloadObjectTask(context.Context, task.DownloadObjectTask) error

func (*NullModular) HandleGCMetaTask

func (*NullModular) HandleGCMetaTask(context.Context, task.GCMetaTask) error

func (*NullModular) HandleGCObjectTask

func (*NullModular) HandleGCObjectTask(context.Context, task.GCObjectTask) error

func (*NullModular) HandleGCZombiePieceTask

func (*NullModular) HandleGCZombiePieceTask(context.Context, task.GCZombiePieceTask) error

func (*NullModular) HandleReceivePieceTask

func (*NullModular) HandleReceivePieceTask(context.Context, task.ReceivePieceTask) error

func (*NullModular) HandleReplicatePieceApproval

func (*NullModular) HandleReplicatePieceApproval(context.Context, task.ApprovalReplicatePieceTask) (bool, error)

func (*NullModular) HandleReplicatePieceTask

func (*NullModular) HandleReplicatePieceTask(context.Context, task.ReplicatePieceTask) error

func (*NullModular) HandleSealObjectTask

func (*NullModular) HandleSealObjectTask(context.Context, task.SealObjectTask) error

func (*NullModular) HandleUploadObjectTask

func (*NullModular) HandleUploadObjectTask(ctx context.Context, task task.UploadObjectTask, stream io.Reader) error

func (*NullModular) Name

func (*NullModular) Name() string

func (*NullModular) PostCreateBucketApproval

func (*NullModular) PostCreateBucketApproval(context.Context, task.ApprovalCreateBucketTask)

func (*NullModular) PostCreateObjectApproval

func (*NullModular) PostCreateObjectApproval(context.Context, task.ApprovalCreateObjectTask)

func (*NullModular) PostReplicatePieceApproval

func (*NullModular) PostReplicatePieceApproval(context.Context, task.ApprovalReplicatePieceTask)

func (*NullModular) PostUploadObject

func (*NullModular) PostUploadObject(ctx context.Context, task task.UploadObjectTask)

func (*NullModular) PreCreateBucketApproval

func (*NullModular) PreCreateBucketApproval(context.Context, task.ApprovalCreateBucketTask) error

func (*NullModular) PreCreateObjectApproval

func (*NullModular) PreCreateObjectApproval(context.Context, task.ApprovalCreateObjectTask) error

func (*NullModular) PreReplicatePieceApproval

func (*NullModular) PreReplicatePieceApproval(context.Context, task.ApprovalReplicatePieceTask) error

func (*NullModular) PreUploadObject

func (*NullModular) PreUploadObject(ctx context.Context, task task.UploadObjectTask) error

func (*NullModular) QueryTask

func (*NullModular) QueryTask(context.Context, task.TKey) (task.Task, error)

func (*NullModular) QueryTasks

func (*NullModular) QueryTasks(ctx context.Context, keyPrefix task.TKey) ([]task.Task, error)

func (*NullModular) ReleaseResource

func (*NullModular) ReleaseResource(context.Context, rcmgr.ResourceScopeSpan)

func (*NullModular) ReserveResource

func (*NullModular) Start

func (*NullModular) Start(context.Context) error

func (*NullModular) Stop

func (*NullModular) VerifyAuthorize

func (*NullModular) VerifyAuthorize(context.Context, AuthOpType, string, string, string) (bool, error)

type NullReceiveModular

type NullReceiveModular struct{}

func (*NullReceiveModular) HandleDoneReceivePieceTask

func (*NullReceiveModular) HandleDoneReceivePieceTask(context.Context, task.ReceivePieceTask) ([]byte, []byte, error)

func (*NullReceiveModular) HandleReceivePieceTask

func (*NullReceiveModular) HandleReceivePieceTask(context.Context, task.ReceivePieceTask, []byte) error

func (*NullReceiveModular) Name

func (*NullReceiveModular) Name() string

func (*NullReceiveModular) QueryTasks

func (*NullReceiveModular) QueryTasks(ctx context.Context, keyPrefix task.TKey) ([]task.Task, error)

func (*NullReceiveModular) ReleaseResource

func (*NullReceiveModular) ReserveResource

func (*NullReceiveModular) Start

func (*NullReceiveModular) Stop

type P2P

type P2P interface {
	Modular
	// HandleReplicatePieceApproval handles the ask replicate piece approval, it will
	// broadcast the approval to other SPs, wait the responses, if up to min approved
	// number or max approved number before timeout, will return the approvals.
	HandleReplicatePieceApproval(ctx context.Context, task task.ApprovalReplicatePieceTask,
		min, max int32, timeout int64) ([]task.ApprovalReplicatePieceTask, error)
	// HandleQueryBootstrap handles the query p2p node bootstrap node info.
	HandleQueryBootstrap(ctx context.Context) ([]string, error)
	// QueryTasks queries replicate piece approval tasks that running on p2p by task
	// sub key.
	QueryTasks(ctx context.Context, subKey task.TKey) ([]task.Task, error)
}

P2P is the interface to the interaction of control information between Sps.

type Receiver

type Receiver interface {
	Modular
	// HandleReceivePieceTask stores the piece data from primary SP.
	HandleReceivePieceTask(ctx context.Context, task task.ReceivePieceTask, data []byte) error
	// HandleDoneReceivePieceTask calculates the integrity hash of the object and sign
	// it, returns to the primary SP for seal object.
	HandleDoneReceivePieceTask(ctx context.Context, task task.ReceivePieceTask) ([]byte, []byte, error)
	// QueryTasks queries replicate piece tasks that running on receiver by task sub
	// key.
	QueryTasks(ctx context.Context, subKey task.TKey) ([]task.Task, error)
}

Receiver is the interface to receive the piece data from primary SP.

type Signer

type Signer interface {
	Modular
	// SignCreateBucketApproval signs the MsgCreateBucket for asking create bucket
	// approval.
	SignCreateBucketApproval(ctx context.Context, bucket *storagetypes.MsgCreateBucket) ([]byte, error)
	// SignCreateObjectApproval signs the MsgCreateObject for asking create object
	// approval.
	SignCreateObjectApproval(ctx context.Context, task *storagetypes.MsgCreateObject) ([]byte, error)
	// SignReplicatePieceApproval signs the ApprovalReplicatePieceTask for asking
	// replicate pieces to secondary SPs.
	SignReplicatePieceApproval(ctx context.Context, task task.ApprovalReplicatePieceTask) ([]byte, error)
	// SignReceivePieceTask signs the ReceivePieceTask for replicating pieces data
	// between SPs.
	SignReceivePieceTask(ctx context.Context, task task.ReceivePieceTask) ([]byte, error)
	// SignIntegrityHash signs the integrity hash of object for sealing object.
	SignIntegrityHash(ctx context.Context, objectID uint64, hash [][]byte) ([]byte, []byte, error)
	// SignP2PPingMsg signs the ping msg for p2p node probing.
	SignP2PPingMsg(ctx context.Context, ping *gfspp2p.GfSpPing) ([]byte, error)
	// SignP2PPongMsg signs the pong msg for p2p to response ping msg.
	SignP2PPongMsg(ctx context.Context, pong *gfspp2p.GfSpPong) ([]byte, error)
	// SealObject signs the MsgSealObject and broadcast the tx to greenfield.
	SealObject(ctx context.Context, object *storagetypes.MsgSealObject) error
}

Signer is the interface to handle the SP's sign and on greenfield chain operator. It holds SP all private key. Considering the sp account's sequence number, it must be a singleton.

type TaskExecutor

type TaskExecutor interface {
	Modular
	// AskTask asks the task by remaining limit from manager modular.
	AskTask(ctx context.Context, remaining rcmgr.Limit)
	// HandleReplicatePieceTask handles the ReplicatePieceTask that is asked from
	// manager modular.
	HandleReplicatePieceTask(ctx context.Context, task task.ReplicatePieceTask)
	// HandleSealObjectTask handles the SealObjectTask that is asked from manager
	// modular.
	HandleSealObjectTask(ctx context.Context, task task.SealObjectTask)
	// HandleReceivePieceTask handles the ReceivePieceTask that is asked from manager
	// modular. It will confirm the object that as secondary SP whether has been sealed.
	HandleReceivePieceTask(ctx context.Context, task task.ReceivePieceTask)
	// HandleGCObjectTask handles the GCObjectTask that is asked from manager modular.
	HandleGCObjectTask(ctx context.Context, task task.GCObjectTask)
	// HandleGCZombiePieceTask handles the GCZombiePieceTask that is asked from manager
	// modular.
	HandleGCZombiePieceTask(ctx context.Context, task task.GCZombiePieceTask)
	// HandleGCMetaTask handles the GCMetaTask that is asked from manager modular.
	HandleGCMetaTask(ctx context.Context, task task.GCMetaTask)
	// ReportTask reports the result or status of running task to manager modular.
	ReportTask(ctx context.Context, task task.Task) error
}

TaskExecutor is the interface to handle background task, it will ask task from manager modular, handle the task and report the result or status to the manager modular includes: ReplicatePieceTask, SealObjectTask, ReceivePieceTask, GCObjectTask GCZombiePieceTask, GCMetaTask.

type Uploader

type Uploader interface {
	Modular
	// PreUploadObject prepares to handle UploadObject, it can do some checks
	// Example: check for duplicates, if limit specified by SP is reached, etc.
	PreUploadObject(ctx context.Context, task task.UploadObjectTask) error
	// HandleUploadObjectTask handles the UploadObject, store the payload data
	// to piece store by data stream.
	HandleUploadObjectTask(ctx context.Context, task task.UploadObjectTask, stream io.Reader) error
	// PostUploadObject is called after HandleUploadObjectTask, it can recycle
	// resources, statistics and other operations.
	PostUploadObject(ctx context.Context, task task.UploadObjectTask)
	// QueryTasks queries upload object tasks that running on uploading by task
	// sub key.
	QueryTasks(ctx context.Context, subKey task.TKey) ([]task.Task, error)
}

Uploader is the interface to handle put object request from user account, and store it in primary SP's piece store.

Jump to

Keyboard shortcuts

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