Skip to content
This repository was archived by the owner on Dec 20, 2024. It is now read-only.

Commit

Permalink
optimize from Reviewers
Browse files Browse the repository at this point in the history
Signed-off-by: lihongyun <[email protected]>
  • Loading branch information
lihongyun committed Apr 8, 2021
1 parent 725d7f3 commit 6d7b2cb
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion apis/types/task_create_request.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions supernode/config/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ const (
)

// Pattern
type Pattern int32

const (
P2pPattern = int32(0)
CdnPattern = int32(1)
P2pPattern = Pattern(0)
CdnPattern = Pattern(1)
)
2 changes: 1 addition & 1 deletion supernode/daemon/mgr/progress/progress_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func NewManager(cfg *config.Config) (*Manager, error) {
}

// InitProgress inits the correlation information between peers and pieces, etc.
func (pm *Manager) InitProgress(ctx context.Context, taskID, peerID, clientID string, peerPattern int32) (err error) {
func (pm *Manager) InitProgress(ctx context.Context, taskID, peerID, clientID string, peerPattern config.Pattern) (err error) {
// validate the param
if stringutils.IsEmptyStr(taskID) {
return errors.Wrap(errortypes.ErrEmptyValue, "taskID")
Expand Down
2 changes: 1 addition & 1 deletion supernode/daemon/mgr/progress/progress_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type peerState struct {
serviceDownTime int64

// ServicePattern default 0 is p2p, 1 is cdn.
peerPattern int32
peerPattern config.Pattern
}

type superLoadState struct {
Expand Down
5 changes: 3 additions & 2 deletions supernode/daemon/mgr/progress_mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package mgr

import (
"context"
"github.com/dragonflyoss/Dragonfly/supernode/config"

"github.com/dragonflyoss/Dragonfly/apis/types"
"github.com/dragonflyoss/Dragonfly/pkg/atomiccount"
Expand All @@ -42,13 +43,13 @@ type PeerState struct {
ServiceDownTime int64

// ServicePattern default 0 is p2p, 1 is cdn.
PeerPattern int32
PeerPattern config.Pattern
}

// ProgressMgr is responsible for maintaining the correspondence between peer and pieces.
type ProgressMgr interface {
// InitProgress inits the correlation information between peers and pieces, etc.
InitProgress(ctx context.Context, taskID, peerID, clientID string, peerPattern int32) error
InitProgress(ctx context.Context, taskID, peerID, clientID string, peerPattern config.Pattern) error

// UpdateProgress updates the correlation information between peers and pieces.
// 1. update the info about srcCID to tell the scheduler that corresponding peer has the piece now.
Expand Down

0 comments on commit 6d7b2cb

Please sign in to comment.