diff --git a/supernode/daemon/mgr/cdn_mgr.go b/supernode/daemon/mgr/cdn_mgr.go index c5461ba33..d09313b85 100644 --- a/supernode/daemon/mgr/cdn_mgr.go +++ b/supernode/daemon/mgr/cdn_mgr.go @@ -38,7 +38,7 @@ type CDNMgr interface { // GetHTTPPath returns the http download path of taskID. GetHTTPPath(ctx context.Context, taskID string) (path string, err error) - // GetStatus get the status of the file. + // GetStatus gets the status of the file. GetStatus(ctx context.Context, taskID string) (cdnStatus string, err error) // Delete the cdn meta with specified taskID. diff --git a/supernode/daemon/mgr/dfget_task_mgr.go b/supernode/daemon/mgr/dfget_task_mgr.go index 7aafc48a6..db1a5ce6e 100644 --- a/supernode/daemon/mgr/dfget_task_mgr.go +++ b/supernode/daemon/mgr/dfget_task_mgr.go @@ -49,7 +49,7 @@ type DfgetTaskMgr interface { // Delete a dfgetTask with clientID and taskID. Delete(ctx context.Context, clientID, taskID string) error - // UpdateStatus update the status of dfgetTask with specified clientID and taskID. + // UpdateStatus updates the status of dfgetTask with specified clientID and taskID. // Supernode will update the status of dfgetTask in the following situations: // 1. after init the dfgetTask // 2. when success/fail to download some pieces diff --git a/supernode/daemon/mgr/gc/gc_manager.go b/supernode/daemon/mgr/gc/gc_manager.go index ec1dda195..43be9f8c4 100644 --- a/supernode/daemon/mgr/gc/gc_manager.go +++ b/supernode/daemon/mgr/gc/gc_manager.go @@ -53,7 +53,7 @@ func NewManager(cfg *config.Config, taskMgr mgr.TaskMgr, peerMgr mgr.PeerMgr, }, nil } -// StartGC start to do the gc jobs. +// StartGC starts to do the gc jobs. func (gcm *Manager) StartGC(ctx context.Context) { logrus.Debugf("start the gc job") diff --git a/supernode/daemon/mgr/peer/manager.go b/supernode/daemon/mgr/peer/manager.go index c0fadbe27..841a2e3ad 100644 --- a/supernode/daemon/mgr/peer/manager.go +++ b/supernode/daemon/mgr/peer/manager.go @@ -55,7 +55,7 @@ type Manager struct { metrics *metrics } -// NewManager return a new Manager Object. +// NewManager returns a new Manager Object. func NewManager(register prometheus.Registerer) (*Manager, error) { return &Manager{ peerStore: dutil.NewStore(), diff --git a/supernode/daemon/mgr/progress/progress_util.go b/supernode/daemon/mgr/progress/progress_util.go index df2371010..d7dcef232 100644 --- a/supernode/daemon/mgr/progress/progress_util.go +++ b/supernode/daemon/mgr/progress/progress_util.go @@ -31,7 +31,7 @@ import ( "github.com/willf/bitset" ) -// updatePieceProgress added a new peer for the pieceNum when the srcPID successfully downloads the piece. +// updatePieceProgress adds a new peer for the pieceNum when the srcPID successfully downloads the piece. func (pm *Manager) updatePieceProgress(taskID, srcPID string, pieceNum int) error { key, err := generatePieceProgressKey(taskID, pieceNum) if err != nil { @@ -90,7 +90,7 @@ func (pm *Manager) updateClientProgress(taskID, srcCID, dstPID string, pieceNum, return updatePieceBitSet(cs.pieceBitSet, pieceNum, pieceStatus), nil } -// updateRunningPiece update the relationship between the running piece and srcCID and dstPID, +// updateRunningPiece updates the relationship between the running piece and srcCID and dstPID, // which means the info that records the pieces being downloaded from dstPID to srcCID. func updateRunningPiece(dstPIDMap *syncmap.SyncMap, srcCID, dstPID string, pieceNum, pieceStatus int) error { pieceNumString := strconv.Itoa(pieceNum) @@ -130,7 +130,7 @@ func updatePieceBitSet(pieceBitSet *bitset.BitSet, pieceNum, pieceStatus int) bo return true } -// updatePeerProgress update the peer progress. +// updatePeerProgress updates the peer progress. func (pm *Manager) updatePeerProgress(taskID, srcPID, dstPID string, pieceNum, pieceStatus int) error { var dstPeerState *peerState @@ -232,7 +232,7 @@ func processPeerFailInfo(srcPeerState, dstPeerState *peerState) { } } -// updateProducerLoad update the load of the clientID. +// updateProducerLoad updates the load of the clientID. // TODO: avoid multiple calls func updateProducerLoad(load *atomiccount.AtomicInt, taskID, peerID string, pieceNum, pieceStatus int) { // increase the load of peerID when pieceStatus equals PieceRUNNING diff --git a/supernode/httpclient/origin_http_client.go b/supernode/httpclient/origin_http_client.go index 5733bdedc..e8cfbff3f 100644 --- a/supernode/httpclient/origin_http_client.go +++ b/supernode/httpclient/origin_http_client.go @@ -56,7 +56,7 @@ func NewOriginClient() OriginHTTPClient { } } -// RegisterTLSConfig save tls config into map as http client. +// RegisterTLSConfig saves tls config into map as http client. // tlsMap: // key->host value->*http.Client func (client *OriginClient) RegisterTLSConfig(rawURL string, insecure bool, caBlock []strfmt.Base64) { @@ -94,7 +94,7 @@ func (client *OriginClient) RegisterTLSConfig(rawURL string, insecure bool, caBl }) } -// GetContentLength send a head request to get file length. +// GetContentLength sends a head request to get file length. func (client *OriginClient) GetContentLength(url string, headers map[string]string) (int64, int, error) { // send request resp, err := client.HTTPWithHeaders("GET", url, headers, 4*time.Second) @@ -169,7 +169,7 @@ func (client *OriginClient) Download(url string, headers map[string]string, chec return nil, fmt.Errorf("unexpected status code: %d", resp.StatusCode) } -// HTTPWithHeaders use host-matched client to request the origin resource. +// HTTPWithHeaders uses host-matched client to request the origin resource. func (client *OriginClient) HTTPWithHeaders(method, url string, headers map[string]string, timeout time.Duration) (*http.Response, error) { req, err := http.NewRequest(method, url, nil) if err != nil { diff --git a/supernode/plugins/plugin_manager.go b/supernode/plugins/plugin_manager.go index 87b99a374..af6d8e6de 100644 --- a/supernode/plugins/plugin_manager.go +++ b/supernode/plugins/plugin_manager.go @@ -22,7 +22,7 @@ import ( "github.com/dragonflyoss/Dragonfly/supernode/config" ) -// NewManager create a default plugin manager instant. +// NewManager creates a default plugin manager instant. func NewManager() Manager { return &managerIml{ builders: NewRepository(), @@ -30,7 +30,7 @@ func NewManager() Manager { } } -// NewRepository create a default repository instant. +// NewRepository creates a default repository instant. func NewRepository() Repository { return &repositoryIml{ repos: make(map[config.PluginType]*sync.Map), @@ -45,7 +45,7 @@ type Manager interface { // GetBuilder returns a Builder object with the giving plugin type and name. GetBuilder(pt config.PluginType, name string) Builder - // DeleteBuilder delete a builder with the giving plugin type and name. + // DeleteBuilder deletes a builder with the giving plugin type and name. DeleteBuilder(pt config.PluginType, name string) // AddPlugin adds a plugin into this manager. diff --git a/supernode/plugins/plugins.go b/supernode/plugins/plugins.go index 8a5084943..40589d03e 100644 --- a/supernode/plugins/plugins.go +++ b/supernode/plugins/plugins.go @@ -26,7 +26,7 @@ import ( var mgr = NewManager() -// SetManager set a Manager implementation instead of the default one. +// SetManager sets a Manager implementation instead of the default one. func SetManager(m Manager) { mgr = m } diff --git a/supernode/server/result_info.go b/supernode/server/result_info.go index cf1b657dc..2922a304c 100644 --- a/supernode/server/result_info.go +++ b/supernode/server/result_info.go @@ -95,7 +95,7 @@ func (r ResultInfo) Error() string { return fmt.Sprintf("{\"Code\":%d,\"Msg\":\"%s\"}", r.code, r.msg) } -// SuccessCode return whether the code equals SuccessCode. +// SuccessCode returns whether the code equals SuccessCode. func (r ResultInfo) SuccessCode() bool { return r.code == constants.Success } diff --git a/supernode/store/errors.go b/supernode/store/errors.go index 48e8888a6..eccb1e213 100644 --- a/supernode/store/errors.go +++ b/supernode/store/errors.go @@ -54,27 +54,27 @@ func (s StorageError) Error() string { return fmt.Sprintf("{\"Code\":%d,\"Msg\":\"%s\"}", s.Code, s.Msg) } -// IsNilError check the error is nil or not. +// IsNilError checks the error is nil or not. func IsNilError(err error) bool { return err == nil } -// IsKeyNotFound check the error is the key cannot be found. +// IsKeyNotFound checks the error is the key cannot be found. func IsKeyNotFound(err error) bool { return checkError(err, codeKeyNotFound) } -// IsEmptyKey check the error is the key is empty or nil. +// IsEmptyKey checks the error is the key is empty or nil. func IsEmptyKey(err error) bool { return checkError(err, codeEmptyKey) } -// IsInvalidValue check the error is the value is invalid or not. +// IsInvalidValue checks the error is the value is invalid or not. func IsInvalidValue(err error) bool { return checkError(err, codeInvalidValue) } -// IsRangeNotSatisfiable check the error is a +// IsRangeNotSatisfiable checks the error is a // range not exist error or not. func IsRangeNotSatisfiable(err error) bool { return checkError(err, codeRangeNotSatisfiable) diff --git a/supernode/store/local_storage.go b/supernode/store/local_storage.go index 0375e0624..5ecccb11c 100644 --- a/supernode/store/local_storage.go +++ b/supernode/store/local_storage.go @@ -230,7 +230,7 @@ func (ls *localStorage) PutBytes(ctx context.Context, raw *Raw, data []byte) err return nil } -// Stat determine whether the file exists. +// Stat determines whether the file exists. func (ls *localStorage) Stat(ctx context.Context, raw *Raw) (*StorageInfo, error) { _, fileInfo, err := ls.statPath(raw.Bucket, raw.Key) if err != nil { diff --git a/supernode/store/storage_driver.go b/supernode/store/storage_driver.go index 29dd2ddbe..1251958a5 100644 --- a/supernode/store/storage_driver.go +++ b/supernode/store/storage_driver.go @@ -53,7 +53,7 @@ type StorageDriver interface { // Remove the data from the storage based on raw information. Remove(ctx context.Context, raw *Raw) error - // Stat determine whether the data exists based on raw information. + // Stat determines whether the data exists based on raw information. // If that, and return some info that in the form of struct StorageInfo. // If not, return the ErrNotFound. Stat(ctx context.Context, raw *Raw) (*StorageInfo, error) diff --git a/supernode/store/store.go b/supernode/store/store.go index 5d969c02d..cc378267f 100644 --- a/supernode/store/store.go +++ b/supernode/store/store.go @@ -37,7 +37,7 @@ type Store struct { driver StorageDriver } -// NewStore create a new Store instance. +// NewStore creates a new Store instance. func NewStore(name string, builder StorageBuilder, cfg string) (*Store, error) { if name == "" || builder == nil { return nil, fmt.Errorf("plugin name or builder cannot be nil") @@ -56,12 +56,12 @@ func NewStore(name string, builder StorageBuilder, cfg string) (*Store, error) { }, nil } -// Type return the plugin type: StoragePlugin. +// Type returns the plugin type: StoragePlugin. func (s *Store) Type() config.PluginType { return config.StoragePlugin } -// Name return the plugin name. +// Name returns the plugin name. func (s *Store) Name() string { return s.driverName } @@ -107,7 +107,7 @@ func (s *Store) Remove(ctx context.Context, raw *Raw) error { return s.driver.Remove(ctx, raw) } -// Stat determine whether the data exists based on raw information. +// Stat determines whether the data exists based on raw information. // If that, and return some info that in the form of struct StorageInfo. // If not, return the ErrNotFound. func (s *Store) Stat(ctx context.Context, raw *Raw) (*StorageInfo, error) { diff --git a/supernode/store/store_mgr.go b/supernode/store/store_mgr.go index 03a7c303e..3ee1ebb53 100644 --- a/supernode/store/store_mgr.go +++ b/supernode/store/store_mgr.go @@ -38,7 +38,7 @@ func Register(name string, builder StorageBuilder) { plugins.RegisterPlugin(config.StoragePlugin, name, f) } -// Manager manage stores. +// Manager manages stores. type Manager struct { cfg *config.Config @@ -46,7 +46,7 @@ type Manager struct { mutex sync.Mutex } -// NewManager create a store manager. +// NewManager creates a store manager. func NewManager(cfg *config.Config) (*Manager, error) { return &Manager{ cfg: cfg, diff --git a/test/command/cmd.go b/test/command/cmd.go index a7d31acc4..0cfaba32c 100644 --- a/test/command/cmd.go +++ b/test/command/cmd.go @@ -67,7 +67,7 @@ func checkExist(s string) { } } -// NewStarter create an instance of Starter. +// NewStarter creates an instance of Starter. // It checks the binary files whether is existing and creates a temporary // directory for testing. func NewStarter(name string) *Starter { @@ -161,7 +161,7 @@ func (s *Starter) Supernode(running time.Duration, args ...string) ( return cmd, err } -// WriteSupernodeFileServer write a file to the supernode file server. +// WriteSupernodeFileServer writes a file to the supernode file server. func (s *Starter) WriteSupernodeFileServer(filePath string, data []byte, perm os.FileMode) error { return ioutil.WriteFile(fp.Join(s.supernodeFileServerHome, filePath), data, perm) } diff --git a/test/request/request.go b/test/request/request.go index a90fb6a98..5a46df68b 100644 --- a/test/request/request.go +++ b/test/request/request.go @@ -57,7 +57,7 @@ func WithQuery(query url.Values) Option { } } -// WithRawData sets the input data with raw data +// WithRawData sets the input data with raw data. func WithRawData(data io.ReadCloser) Option { return func(r *http.Request) error { r.Body = data @@ -65,7 +65,7 @@ func WithRawData(data io.ReadCloser) Option { } } -// WithJSONBody encodes the input data to JSON and sets it to the body in http.Request +// WithJSONBody encodes the input data to JSON and sets it to the body in http.Request. func WithJSONBody(obj interface{}) Option { return func(r *http.Request) error { b := bytes.NewBuffer([]byte{})