This repository has been archived by the owner on Dec 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 773
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: implement the cdn manager framework
Signed-off-by: Starnop <[email protected]>
- Loading branch information
Showing
6 changed files
with
105 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package cdn | ||
|
||
import ( | ||
"context" | ||
"hash" | ||
|
||
"github.com/dragonflyoss/Dragonfly/apis/types" | ||
) | ||
|
||
type cacheResult struct { | ||
startPieceNum int | ||
pieceMd5s []string | ||
fileMD5 hash.Hash | ||
} | ||
|
||
// detectCache detects whether there is a corresponding file in the local. | ||
// If any, check whether the entire file has been completely downloaded. | ||
// | ||
// If so, return the md5 of task file and return startPieceNum as -1. | ||
// And if not, return the lastest piece num that has been downloaded. | ||
func (cm *Manager) detectCache(ctx context.Context, task *types.TaskInfo) (*cacheResult, error) { | ||
// TODO: implement it. | ||
return nil, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package cdn | ||
|
||
import ( | ||
"context" | ||
"net/http" | ||
|
||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
// download the file from the original address and | ||
// set the "Range" header to the undownloaded file range. | ||
func (cm *Manager) download(ctx context.Context, taskID, url string, headers map[string]string, startPieceNum int, httpFileLength int64, pieceContSize int32) (*http.Response, error) { | ||
logrus.Infof("start to download for taskId:%s, fileUrl:%s", taskID, url) | ||
return nil, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package cdn | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/dragonflyoss/Dragonfly/apis/types" | ||
cutil "github.com/dragonflyoss/Dragonfly/common/util" | ||
"github.com/dragonflyoss/Dragonfly/supernode/config" | ||
) | ||
|
||
// startWriter writes the stream data from the reader to the underlying storage. | ||
func (cm *Manager) startWriter(ctx context.Context, cfg *config.Config, reader *cutil.LimitReader, | ||
task *types.TaskInfo, startPieceNum int, httpFileLength int64, pieceContSize int32) error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters