Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
modify document
Browse files Browse the repository at this point in the history
Signed-off-by: chentanjun <[email protected]>
  • Loading branch information
tanjunchen committed Sep 17, 2019
1 parent a6bfdf9 commit fcd8ec7
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion supernode/daemon/mgr/cdn_mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion supernode/daemon/mgr/dfget_task_mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion supernode/daemon/mgr/gc/gc_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion supernode/daemon/mgr/peer/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
8 changes: 4 additions & 4 deletions supernode/daemon/mgr/progress/progress_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions supernode/httpclient/origin_http_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions supernode/plugins/plugin_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ 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(),
plugins: NewRepository(),
}
}

// NewRepository create a default repository instant.
// NewRepository creates a default repository instant.
func NewRepository() Repository {
return &repositoryIml{
repos: make(map[config.PluginType]*sync.Map),
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion supernode/plugins/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion supernode/server/result_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
10 changes: 5 additions & 5 deletions supernode/store/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion supernode/store/local_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion supernode/store/storage_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions supernode/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
}
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions supernode/store/store_mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ func Register(name string, builder StorageBuilder) {
plugins.RegisterPlugin(config.StoragePlugin, name, f)
}

// Manager manage stores.
// Manager manages stores.
type Manager struct {
cfg *config.Config

defaultStorage *Store
mutex sync.Mutex
}

// NewManager create a store manager.
// NewManager creates a store manager.
func NewManager(cfg *config.Config) (*Manager, error) {
return &Manager{
cfg: cfg,
Expand Down
4 changes: 2 additions & 2 deletions test/command/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions test/request/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ 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
return nil
}
}

// 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{})
Expand Down

0 comments on commit fcd8ec7

Please sign in to comment.