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

Commit

Permalink
feature: implement the task mgr
Browse files Browse the repository at this point in the history
Signed-off-by: Starnop <[email protected]>
  • Loading branch information
starnop committed Jun 3, 2019
1 parent 496c85e commit 36fba9a
Show file tree
Hide file tree
Showing 17 changed files with 1,092 additions and 262 deletions.
11 changes: 5 additions & 6 deletions apis/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,11 @@ definitions:
downloads, if there is already a task a.b.com/fileA.
items:
type: "string"
peerID:
type: "string"
description: |
PeerID is used to uniquely identifies a peer which will be used to create a dfgetTask.
The value must be the value in the response after registering a peer.
TaskCreateResponse:
type: "object"
Expand Down Expand Up @@ -648,12 +653,6 @@ definitions:
the same taskURL and taskID to download file, A and B will share the same peer network to distribute files.
If user A additionally adds an identifier with taskURL, while user B still carries only taskURL, then A's
generated taskID is different from B, and the result is that two users use different peer networks.
path:
type: "string"
description: |
path is used in one peer A for uploading functionality. When peer B hopes
to get piece C from peer A, B must provide a URL for piece C.
Then when creating a task in supernode, peer A must provide this URL in request.
headers:
type: "object"
description: |
Expand Down
5 changes: 5 additions & 0 deletions 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: 0 additions & 6 deletions apis/types/task_info.go

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

3 changes: 3 additions & 0 deletions common/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ const (
codePeerWait
codeUnknowError
codePeerContinue
codeURLNotReachable
codeTaskIDDuplicate
codeAuthenticationRequired
)

// DfError represents a Dragonfly error.
Expand Down
24 changes: 24 additions & 0 deletions common/errors/supernode_errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ var (

// PeerContinue represents the peer should wait.
PeerContinue = DfError{codePeerContinue, "peer continue"}

// ErrURLNotReachable represents the url is a not reachable.
ErrURLNotReachable = DfError{codeURLNotReachable, "url not reachable"}

// ErrTaskIDDuplicate represents the task id is in conflict.
ErrTaskIDDuplicate = DfError{codeTaskIDDuplicate, "taskId conflict"}

// ErrAuthenticationRequired represents the authentication is required.
ErrAuthenticationRequired = DfError{codeAuthenticationRequired, "authentication required"}
)

// IsSystemError check the error is a system error or not.
Expand Down Expand Up @@ -67,3 +76,18 @@ func IsUnknowError(err error) bool {
func IsPeerContinue(err error) bool {
return checkError(err, codePeerContinue)
}

// IsURLNotReachable check the error is a url not reachable or not.
func IsURLNotReachable(err error) bool {
return checkError(err, codeURLNotReachable)
}

// IsTaskIDDuplicate check the error is a TaskIDDuplicate error or not.
func IsTaskIDDuplicate(err error) bool {
return checkError(err, codeTaskIDDuplicate)
}

// IsAuthenticationRequired check the error is a AuthenticationRequired error or not.
func IsAuthenticationRequired(err error) bool {
return checkError(err, codeAuthenticationRequired)
}
223 changes: 0 additions & 223 deletions dfget/util/http_util.go

This file was deleted.

Loading

0 comments on commit 36fba9a

Please sign in to comment.