feat: remove callsystem and pattern (#1925)
Signed-off-by: Gaius <gaius.qi@gmail.com>
This commit is contained in:
parent
73ebf093bb
commit
91454c8a60
|
|
@ -18,7 +18,6 @@ dfcache delete <-i cid> [flags]
|
||||||
.IP
|
.IP
|
||||||
.nf
|
.nf
|
||||||
\f[C]
|
\f[C]
|
||||||
--callsystem string The caller name which is mainly used for statistics and access control
|
|
||||||
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
||||||
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
||||||
--console whether logger output records to the stdout
|
--console whether logger output records to the stdout
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ dfcache doc [flags]
|
||||||
.IP
|
.IP
|
||||||
.nf
|
.nf
|
||||||
\f[C]
|
\f[C]
|
||||||
--callsystem string The caller name which is mainly used for statistics and access control
|
|
||||||
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
||||||
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
||||||
--console whether logger output records to the stdout
|
--console whether logger output records to the stdout
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ dfcache export <-i cid> <output>|<-O output> [flags]
|
||||||
.IP
|
.IP
|
||||||
.nf
|
.nf
|
||||||
\f[C]
|
\f[C]
|
||||||
--callsystem string The caller name which is mainly used for statistics and access control
|
|
||||||
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
||||||
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
||||||
--console whether logger output records to the stdout
|
--console whether logger output records to the stdout
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ dfcache import <-i cid> <file>|<-I file> [flags]
|
||||||
.IP
|
.IP
|
||||||
.nf
|
.nf
|
||||||
\f[C]
|
\f[C]
|
||||||
--callsystem string The caller name which is mainly used for statistics and access control
|
|
||||||
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
||||||
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
||||||
--console whether logger output records to the stdout
|
--console whether logger output records to the stdout
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ dfcache plugin [flags]
|
||||||
.IP
|
.IP
|
||||||
.nf
|
.nf
|
||||||
\f[C]
|
\f[C]
|
||||||
--callsystem string The caller name which is mainly used for statistics and access control
|
|
||||||
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
||||||
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
||||||
--console whether logger output records to the stdout
|
--console whether logger output records to the stdout
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ dfcache stat <-i cid> [flags]
|
||||||
.IP
|
.IP
|
||||||
.nf
|
.nf
|
||||||
\f[C]
|
\f[C]
|
||||||
--callsystem string The caller name which is mainly used for statistics and access control
|
|
||||||
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
||||||
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
||||||
--console whether logger output records to the stdout
|
--console whether logger output records to the stdout
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ dfcache version [flags]
|
||||||
.IP
|
.IP
|
||||||
.nf
|
.nf
|
||||||
\f[C]
|
\f[C]
|
||||||
--callsystem string The caller name which is mainly used for statistics and access control
|
|
||||||
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
||||||
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
||||||
--console whether logger output records to the stdout
|
--console whether logger output records to the stdout
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ network.
|
||||||
.IP
|
.IP
|
||||||
.nf
|
.nf
|
||||||
\f[C]
|
\f[C]
|
||||||
--callsystem string The caller name which is mainly used for statistics and access control
|
|
||||||
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
||||||
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
||||||
--console whether logger output records to the stdout
|
--console whether logger output records to the stdout
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ responsibility to go back to source and add file into P2P network.
|
||||||
## OPTIONS
|
## OPTIONS
|
||||||
|
|
||||||
```
|
```
|
||||||
--callsystem string The caller name which is mainly used for statistics and access control
|
|
||||||
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
||||||
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
||||||
--console whether logger output records to the stdout
|
--console whether logger output records to the stdout
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ dfcache delete <-i cid> [flags]
|
||||||
## OPTIONS
|
## OPTIONS
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
--callsystem string The caller name which is mainly used for statistics and access control
|
|
||||||
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
||||||
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
||||||
--console whether logger output records to the stdout
|
--console whether logger output records to the stdout
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ dfcache doc [flags]
|
||||||
## OPTIONS
|
## OPTIONS
|
||||||
|
|
||||||
```
|
```
|
||||||
--callsystem string The caller name which is mainly used for statistics and access control
|
|
||||||
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
||||||
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
||||||
--console whether logger output records to the stdout
|
--console whether logger output records to the stdout
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ dfcache export <-i cid> <output>|<-O output> [flags]
|
||||||
## OPTIONS
|
## OPTIONS
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
--callsystem string The caller name which is mainly used for statistics and access control
|
|
||||||
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
||||||
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
||||||
--console whether logger output records to the stdout
|
--console whether logger output records to the stdout
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ dfcache import <-i cid> <file>|<-I file> [flags]
|
||||||
## OPTIONS
|
## OPTIONS
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
--callsystem string The caller name which is mainly used for statistics and access control
|
|
||||||
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
||||||
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
||||||
--console whether logger output records to the stdout
|
--console whether logger output records to the stdout
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ dfcache plugin [flags]
|
||||||
## OPTIONS
|
## OPTIONS
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
--callsystem string The caller name which is mainly used for statistics and access control
|
|
||||||
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
||||||
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
||||||
--console whether logger output records to the stdout
|
--console whether logger output records to the stdout
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ dfcache stat <-i cid> [flags]
|
||||||
## OPTIONS
|
## OPTIONS
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
--callsystem string The caller name which is mainly used for statistics and access control
|
|
||||||
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
||||||
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
||||||
--console whether logger output records to the stdout
|
--console whether logger output records to the stdout
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ dfcache version [flags]
|
||||||
## OPTIONS
|
## OPTIONS
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
--callsystem string The caller name which is mainly used for statistics and access control
|
|
||||||
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
-i, --cid string content or cache ID, e.g. sha256 digest of the content
|
||||||
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
--config string the path of configuration file with yaml extension name, default is /etc/dragonfly/dfcache.yaml, it can also be set by env var: DFCACHE_CONFIG
|
||||||
--console whether logger output records to the stdout
|
--console whether logger output records to the stdout
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ and so on.
|
||||||
.nf
|
.nf
|
||||||
\f[C]
|
\f[C]
|
||||||
--accept-regex string Recursively download only. Specify a regular expression to accept the complete URL. In this case, you have to enclose the pattern into quotes to prevent your shell from expanding it
|
--accept-regex string Recursively download only. Specify a regular expression to accept the complete URL. In this case, you have to enclose the pattern into quotes to prevent your shell from expanding it
|
||||||
--callsystem string The caller name which is mainly used for statistics and access control
|
|
||||||
--config string the path of configuration file with yaml extension name, it can also be set by env var: DFGET_CONFIG
|
--config string the path of configuration file with yaml extension name, it can also be set by env var: DFGET_CONFIG
|
||||||
--console whether logger output records to the stdout
|
--console whether logger output records to the stdout
|
||||||
--daemon-sock string Download socket path of daemon. In linux, default value is /var/run/dfdaemon.sock, in macos(just for testing), default value is /tmp/dfdaemon.sock
|
--daemon-sock string Download socket path of daemon. In linux, default value is /var/run/dfdaemon.sock, in macos(just for testing), default value is /tmp/dfdaemon.sock
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ functionality, such as network bandwidth limit, transmission encryption and so o
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
--accept-regex string Recursively download only. Specify a regular expression to accept the complete URL. In this case, you have to enclose the pattern into quotes to prevent your shell from expanding it
|
--accept-regex string Recursively download only. Specify a regular expression to accept the complete URL. In this case, you have to enclose the pattern into quotes to prevent your shell from expanding it
|
||||||
--callsystem string The caller name which is mainly used for statistics and access control
|
|
||||||
--config string the path of configuration file with yaml extension name, it can also be set by env var: DFGET_CONFIG
|
--config string the path of configuration file with yaml extension name, it can also be set by env var: DFGET_CONFIG
|
||||||
--console whether logger output records to the stdout
|
--console whether logger output records to the stdout
|
||||||
--daemon-sock string Download socket path of daemon. In linux, default value is /var/run/dfdaemon.sock, in macos(just for testing), default value is /tmp/dfdaemon.sock
|
--daemon-sock string Download socket path of daemon. In linux, default value is /var/run/dfdaemon.sock, in macos(just for testing), default value is /tmp/dfdaemon.sock
|
||||||
|
|
|
||||||
|
|
@ -38,13 +38,6 @@ const (
|
||||||
ForceNotBackSourceAddition = 1000
|
ForceNotBackSourceAddition = 1000
|
||||||
)
|
)
|
||||||
|
|
||||||
// Download pattern.
|
|
||||||
const (
|
|
||||||
PatternP2P = "p2p"
|
|
||||||
PatternSeedPeer = "seed-peer"
|
|
||||||
PatternSource = "source"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Download limit.
|
// Download limit.
|
||||||
const (
|
const (
|
||||||
DefaultPerPeerDownloadLimit = 512 * unit.MB
|
DefaultPerPeerDownloadLimit = 512 * unit.MB
|
||||||
|
|
|
||||||
|
|
@ -49,9 +49,6 @@ type CacheOption struct {
|
||||||
// Timeout operation timeout(second).
|
// Timeout operation timeout(second).
|
||||||
Timeout time.Duration `yaml:"timeout,omitempty" mapstructure:"timeout,omitempty"`
|
Timeout time.Duration `yaml:"timeout,omitempty" mapstructure:"timeout,omitempty"`
|
||||||
|
|
||||||
// CallSystem optional system name
|
|
||||||
CallSystem string `yaml:"callSystem,omitempty" mapstructure:"callSystem,omitempty"`
|
|
||||||
|
|
||||||
// LogDir is log directory of dfcache.
|
// LogDir is log directory of dfcache.
|
||||||
LogDir string `yaml:"logDir,omitempty" mapstructure:"logDir,omitempty"`
|
LogDir string `yaml:"logDir,omitempty" mapstructure:"logDir,omitempty"`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,11 +73,6 @@ type ClientOption struct {
|
||||||
// DaemonSock is daemon download socket path.
|
// DaemonSock is daemon download socket path.
|
||||||
DaemonSock string `yaml:"daemonSock,omitempty" mapstructure:"daemon-sock,omitempty"`
|
DaemonSock string `yaml:"daemonSock,omitempty" mapstructure:"daemon-sock,omitempty"`
|
||||||
|
|
||||||
// Deprecated: use Priority instead
|
|
||||||
// Pattern download pattern, must be 'p2p' or 'seed-peer' or 'source',
|
|
||||||
// default:`p2p`.
|
|
||||||
Pattern string `yaml:"pattern,omitempty" mapstructure:"pattern,omitempty"`
|
|
||||||
|
|
||||||
// Priority scheduler will schedule tasks according to priority
|
// Priority scheduler will schedule tasks according to priority
|
||||||
Priority int32 `yaml:"priority,omitempty" mapstructure:"priority,omitempty"`
|
Priority int32 `yaml:"priority,omitempty" mapstructure:"priority,omitempty"`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,6 @@ var dfgetConfig = ClientOption{
|
||||||
DigestValue: "",
|
DigestValue: "",
|
||||||
Tag: "",
|
Tag: "",
|
||||||
Application: "",
|
Application: "",
|
||||||
Pattern: "",
|
|
||||||
Priority: 0,
|
Priority: 0,
|
||||||
Cacerts: nil,
|
Cacerts: nil,
|
||||||
Filter: "",
|
Filter: "",
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@ var dfgetConfig = ClientOption{
|
||||||
DigestValue: "",
|
DigestValue: "",
|
||||||
Tag: "",
|
Tag: "",
|
||||||
Application: "",
|
Application: "",
|
||||||
Pattern: "",
|
|
||||||
Priority: 0,
|
Priority: 0,
|
||||||
Cacerts: nil,
|
Cacerts: nil,
|
||||||
Filter: "",
|
Filter: "",
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@ import (
|
||||||
|
|
||||||
"d7y.io/dragonfly/v2/client/util"
|
"d7y.io/dragonfly/v2/client/util"
|
||||||
"d7y.io/dragonfly/v2/cmd/dependency/base"
|
"d7y.io/dragonfly/v2/cmd/dependency/base"
|
||||||
logger "d7y.io/dragonfly/v2/internal/dflog"
|
|
||||||
"d7y.io/dragonfly/v2/pkg/dfnet"
|
"d7y.io/dragonfly/v2/pkg/dfnet"
|
||||||
"d7y.io/dragonfly/v2/pkg/net/ip"
|
"d7y.io/dragonfly/v2/pkg/net/ip"
|
||||||
"d7y.io/dragonfly/v2/pkg/types"
|
"d7y.io/dragonfly/v2/pkg/types"
|
||||||
|
|
@ -193,29 +192,9 @@ func (p *DaemonOption) Validate() error {
|
||||||
return errors.New("reload interval too short, must great than 1 second")
|
return errors.New("reload interval too short, must great than 1 second")
|
||||||
}
|
}
|
||||||
|
|
||||||
switch p.Download.DefaultPattern {
|
|
||||||
case PatternP2P, PatternSeedPeer, PatternSource:
|
|
||||||
default:
|
|
||||||
return errors.New("available pattern: p2p, seed-peer, source")
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConvertPattern(p string, defaultPattern commonv1.Pattern) commonv1.Pattern {
|
|
||||||
switch p {
|
|
||||||
case PatternP2P:
|
|
||||||
return commonv1.Pattern_P2P
|
|
||||||
case PatternSeedPeer:
|
|
||||||
return commonv1.Pattern_SEED_PEER
|
|
||||||
case PatternSource:
|
|
||||||
return commonv1.Pattern_SOURCE
|
|
||||||
case "":
|
|
||||||
return defaultPattern
|
|
||||||
}
|
|
||||||
logger.Warnf("unknown pattern, use default pattern: %s", commonv1.Pattern_name[int32(defaultPattern)])
|
|
||||||
return defaultPattern
|
|
||||||
}
|
|
||||||
|
|
||||||
type GlobalSecurityOption struct {
|
type GlobalSecurityOption struct {
|
||||||
// AutoIssueCert indicates to issue client certificates for all grpc call
|
// AutoIssueCert indicates to issue client certificates for all grpc call
|
||||||
// if AutoIssueCert is false, any other option in Security will be ignored
|
// if AutoIssueCert is false, any other option in Security will be ignored
|
||||||
|
|
@ -292,7 +271,6 @@ type HostOption struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type DownloadOption struct {
|
type DownloadOption struct {
|
||||||
DefaultPattern string `mapstructure:"defaultPattern" yaml:"defaultPattern"`
|
|
||||||
TotalRateLimit util.RateLimit `mapstructure:"totalRateLimit" yaml:"totalRateLimit"`
|
TotalRateLimit util.RateLimit `mapstructure:"totalRateLimit" yaml:"totalRateLimit"`
|
||||||
PerPeerRateLimit util.RateLimit `mapstructure:"perPeerRateLimit" yaml:"perPeerRateLimit"`
|
PerPeerRateLimit util.RateLimit `mapstructure:"perPeerRateLimit" yaml:"perPeerRateLimit"`
|
||||||
TrafficShaperType string `mapstructure:"trafficShaperType" yaml:"trafficShaperType"`
|
TrafficShaperType string `mapstructure:"trafficShaperType" yaml:"trafficShaperType"`
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,6 @@ var peerHostConfig = func() *DaemonOption {
|
||||||
NetTopology: "",
|
NetTopology: "",
|
||||||
},
|
},
|
||||||
Download: DownloadOption{
|
Download: DownloadOption{
|
||||||
DefaultPattern: PatternP2P,
|
|
||||||
CalculateDigest: true,
|
CalculateDigest: true,
|
||||||
PieceDownloadTimeout: 30 * time.Second,
|
PieceDownloadTimeout: 30 * time.Second,
|
||||||
GRPCDialTimeout: 10 * time.Second,
|
GRPCDialTimeout: 10 * time.Second,
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,6 @@ var peerHostConfig = func() *DaemonOption {
|
||||||
NetTopology: "",
|
NetTopology: "",
|
||||||
},
|
},
|
||||||
Download: DownloadOption{
|
Download: DownloadOption{
|
||||||
DefaultPattern: PatternP2P,
|
|
||||||
CalculateDigest: true,
|
CalculateDigest: true,
|
||||||
PieceDownloadTimeout: 30 * time.Second,
|
PieceDownloadTimeout: 30 * time.Second,
|
||||||
GRPCDialTimeout: 10 * time.Second,
|
GRPCDialTimeout: 10 * time.Second,
|
||||||
|
|
|
||||||
|
|
@ -291,7 +291,6 @@ func TestPeerHostOption_Load(t *testing.T) {
|
||||||
AdvertiseIP: "0.0.0.0",
|
AdvertiseIP: "0.0.0.0",
|
||||||
},
|
},
|
||||||
Download: DownloadOption{
|
Download: DownloadOption{
|
||||||
DefaultPattern: PatternP2P,
|
|
||||||
TotalRateLimit: util.RateLimit{
|
TotalRateLimit: util.RateLimit{
|
||||||
Limit: 1024 * 1024 * 1024,
|
Limit: 1024 * 1024 * 1024,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@ import (
|
||||||
"google.golang.org/grpc/credentials/insecure"
|
"google.golang.org/grpc/credentials/insecure"
|
||||||
zapadapter "logur.dev/adapter/zap"
|
zapadapter "logur.dev/adapter/zap"
|
||||||
|
|
||||||
commonv1 "d7y.io/api/pkg/apis/common/v1"
|
|
||||||
schedulerv1 "d7y.io/api/pkg/apis/scheduler/v1"
|
schedulerv1 "d7y.io/api/pkg/apis/scheduler/v1"
|
||||||
|
|
||||||
"d7y.io/dragonfly/v2/client/config"
|
"d7y.io/dragonfly/v2/client/config"
|
||||||
|
|
@ -123,9 +122,8 @@ func New(opt *config.DaemonOption, d dfpath.Dfpath) (Daemon, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
managerClient managerclient.Client
|
managerClient managerclient.Client
|
||||||
certifyClient *certify.Certify
|
certifyClient *certify.Certify
|
||||||
defaultPattern = config.ConvertPattern(opt.Download.DefaultPattern, commonv1.Pattern_P2P)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if opt.Scheduler.Manager.Enable {
|
if opt.Scheduler.Manager.Enable {
|
||||||
|
|
@ -288,13 +286,13 @@ func New(opt *config.DaemonOption, d dfpath.Dfpath) (Daemon, error) {
|
||||||
peerServerOption = append(peerServerOption, grpc.Creds(tlsCredentials))
|
peerServerOption = append(peerServerOption, grpc.Creds(tlsCredentials))
|
||||||
}
|
}
|
||||||
|
|
||||||
rpcManager, err := rpcserver.New(host, peerTaskManager, storageManager, defaultPattern,
|
rpcManager, err := rpcserver.New(host, peerTaskManager, storageManager,
|
||||||
opt.Download.RecursiveConcurrent.GoroutineCount, opt.Download.CacheRecursiveMetadata, downloadServerOption, peerServerOption)
|
opt.Download.RecursiveConcurrent.GoroutineCount, opt.Download.CacheRecursiveMetadata, downloadServerOption, peerServerOption)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
proxyManager, err := proxy.NewProxyManager(host, peerTaskManager, defaultPattern, opt.Proxy)
|
proxyManager, err := proxy.NewProxyManager(host, peerTaskManager, opt.Proxy)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,6 @@ type FileTaskRequest struct {
|
||||||
Output string
|
Output string
|
||||||
Limit float64
|
Limit float64
|
||||||
DisableBackSource bool
|
DisableBackSource bool
|
||||||
Callsystem string
|
|
||||||
Range *util.Range
|
Range *util.Range
|
||||||
KeepOriginalOffset bool
|
KeepOriginalOffset bool
|
||||||
}
|
}
|
||||||
|
|
@ -63,8 +62,6 @@ type fileTask struct {
|
||||||
|
|
||||||
// disableBackSource indicates not back source when failed
|
// disableBackSource indicates not back source when failed
|
||||||
disableBackSource bool
|
disableBackSource bool
|
||||||
pattern string
|
|
||||||
callsystem string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProgressState struct {
|
type ProgressState struct {
|
||||||
|
|
@ -113,7 +110,6 @@ func (ptm *peerTaskManager) newFileTask(
|
||||||
progressCh: make(chan *FileTaskProgress),
|
progressCh: make(chan *FileTaskProgress),
|
||||||
progressStopCh: make(chan bool),
|
progressStopCh: make(chan bool),
|
||||||
disableBackSource: request.DisableBackSource,
|
disableBackSource: request.DisableBackSource,
|
||||||
callsystem: request.Callsystem,
|
|
||||||
}
|
}
|
||||||
return ctx, pt, nil
|
return ctx, pt, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -270,7 +270,6 @@ func (ptm *peerTaskManager) prefetchParentTask(request *schedulerv1.PeerTaskRequ
|
||||||
PeerHost: ptm.PeerHost,
|
PeerHost: ptm.PeerHost,
|
||||||
HostLoad: request.HostLoad,
|
HostLoad: request.HostLoad,
|
||||||
IsMigrating: request.IsMigrating,
|
IsMigrating: request.IsMigrating,
|
||||||
Pattern: request.Pattern,
|
|
||||||
UrlMeta: &commonv1.UrlMeta{
|
UrlMeta: &commonv1.UrlMeta{
|
||||||
Digest: request.UrlMeta.Digest,
|
Digest: request.UrlMeta.Digest,
|
||||||
Tag: request.UrlMeta.Tag,
|
Tag: request.UrlMeta.Tag,
|
||||||
|
|
@ -342,7 +341,6 @@ func (ptm *peerTaskManager) StartStreamTask(ctx context.Context, req *StreamTask
|
||||||
PeerHost: ptm.PeerHost,
|
PeerHost: ptm.PeerHost,
|
||||||
HostLoad: nil,
|
HostLoad: nil,
|
||||||
IsMigrating: false,
|
IsMigrating: false,
|
||||||
Pattern: req.Pattern,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ptm.Multiplex {
|
if ptm.Multiplex {
|
||||||
|
|
|
||||||
|
|
@ -776,9 +776,8 @@ func (ts *testSpec) runSeedTaskTest(_ *testifyassert.Assertions, require *testif
|
||||||
HostLoad: nil,
|
HostLoad: nil,
|
||||||
IsMigrating: false,
|
IsMigrating: false,
|
||||||
},
|
},
|
||||||
Limit: 0,
|
Limit: 0,
|
||||||
Callsystem: "",
|
Range: nil,
|
||||||
Range: nil,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
require.Nil(err, "start seed peer task")
|
require.Nil(err, "start seed peer task")
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,8 @@ import (
|
||||||
|
|
||||||
type SeedTaskRequest struct {
|
type SeedTaskRequest struct {
|
||||||
schedulerv1.PeerTaskRequest
|
schedulerv1.PeerTaskRequest
|
||||||
Limit float64
|
Limit float64
|
||||||
Callsystem string
|
Range *util.Range
|
||||||
Range *util.Range
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type SeedTaskResponse struct {
|
type SeedTaskResponse struct {
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,6 @@ type StreamTaskRequest struct {
|
||||||
Range *util.Range
|
Range *util.Range
|
||||||
// peer's id and must be global uniqueness
|
// peer's id and must be global uniqueness
|
||||||
PeerID string
|
PeerID string
|
||||||
// Pattern to register to scheduler
|
|
||||||
Pattern commonv1.Pattern
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// StreamTask represents a peer task with stream io for reading directly without once more disk io
|
// StreamTask represents a peer task with stream io for reading directly without once more disk io
|
||||||
|
|
|
||||||
|
|
@ -104,9 +104,6 @@ type Proxy struct {
|
||||||
// defaultApplication is used when http request without X-Dragonfly-Application Header
|
// defaultApplication is used when http request without X-Dragonfly-Application Header
|
||||||
defaultApplication string
|
defaultApplication string
|
||||||
|
|
||||||
// DEPRECATED
|
|
||||||
defaultPattern commonv1.Pattern
|
|
||||||
|
|
||||||
// defaultPriority is used for scheduling
|
// defaultPriority is used for scheduling
|
||||||
defaultPriority commonv1.Priority
|
defaultPriority commonv1.Priority
|
||||||
|
|
||||||
|
|
@ -249,14 +246,6 @@ func WithDefaultPriority(priority commonv1.Priority) Option {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithDefaultPattern sets default pattern for downloading
|
|
||||||
func WithDefaultPattern(pattern commonv1.Pattern) Option {
|
|
||||||
return func(p *Proxy) *Proxy {
|
|
||||||
p.defaultPattern = pattern
|
|
||||||
return p
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// WithBasicAuth sets basic auth info for proxy
|
// WithBasicAuth sets basic auth info for proxy
|
||||||
func WithBasicAuth(auth *config.BasicAuth) Option {
|
func WithBasicAuth(auth *config.BasicAuth) Option {
|
||||||
return func(p *Proxy) *Proxy {
|
return func(p *Proxy) *Proxy {
|
||||||
|
|
@ -527,7 +516,6 @@ func (proxy *Proxy) newTransport(tlsConfig *tls.Config) http.RoundTripper {
|
||||||
transport.WithTLS(tlsConfig),
|
transport.WithTLS(tlsConfig),
|
||||||
transport.WithCondition(proxy.shouldUseDragonfly),
|
transport.WithCondition(proxy.shouldUseDragonfly),
|
||||||
transport.WithDefaultFilter(proxy.defaultFilter),
|
transport.WithDefaultFilter(proxy.defaultFilter),
|
||||||
transport.WithDefaultPattern(proxy.defaultPattern),
|
|
||||||
transport.WithDefaultTag(proxy.defaultTag),
|
transport.WithDefaultTag(proxy.defaultTag),
|
||||||
transport.WithDefaultApplication(proxy.defaultApplication),
|
transport.WithDefaultApplication(proxy.defaultApplication),
|
||||||
transport.WithDefaultPriority(proxy.defaultPriority),
|
transport.WithDefaultPriority(proxy.defaultPriority),
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ import (
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
|
|
||||||
commonv1 "d7y.io/api/pkg/apis/common/v1"
|
|
||||||
schedulerv1 "d7y.io/api/pkg/apis/scheduler/v1"
|
schedulerv1 "d7y.io/api/pkg/apis/scheduler/v1"
|
||||||
|
|
||||||
"d7y.io/dragonfly/v2/client/config"
|
"d7y.io/dragonfly/v2/client/config"
|
||||||
|
|
@ -60,7 +59,7 @@ type proxyManager struct {
|
||||||
|
|
||||||
var _ Manager = (*proxyManager)(nil)
|
var _ Manager = (*proxyManager)(nil)
|
||||||
|
|
||||||
func NewProxyManager(peerHost *schedulerv1.PeerHost, peerTaskManager peer.TaskManager, defaultPattern commonv1.Pattern, proxyOption *config.ProxyOption) (Manager, error) {
|
func NewProxyManager(peerHost *schedulerv1.PeerHost, peerTaskManager peer.TaskManager, proxyOption *config.ProxyOption) (Manager, error) {
|
||||||
// proxy is option, when nil, just disable it
|
// proxy is option, when nil, just disable it
|
||||||
if proxyOption == nil {
|
if proxyOption == nil {
|
||||||
logger.Infof("proxy config is empty, disabled")
|
logger.Infof("proxy config is empty, disabled")
|
||||||
|
|
@ -82,7 +81,6 @@ func NewProxyManager(peerHost *schedulerv1.PeerHost, peerTaskManager peer.TaskMa
|
||||||
WithDefaultTag(proxyOption.DefaultTag),
|
WithDefaultTag(proxyOption.DefaultTag),
|
||||||
WithDefaultApplication(proxyOption.DefaultApplication),
|
WithDefaultApplication(proxyOption.DefaultApplication),
|
||||||
WithDefaultPriority(proxyOption.DefaultPriority),
|
WithDefaultPriority(proxyOption.DefaultPriority),
|
||||||
WithDefaultPattern(defaultPattern),
|
|
||||||
WithBasicAuth(proxyOption.BasicAuth),
|
WithBasicAuth(proxyOption.BasicAuth),
|
||||||
WithDumpHTTPContent(proxyOption.DumpHTTPContent),
|
WithDumpHTTPContent(proxyOption.DumpHTTPContent),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,6 @@ type server struct {
|
||||||
peerHost *schedulerv1.PeerHost
|
peerHost *schedulerv1.PeerHost
|
||||||
peerTaskManager peer.TaskManager
|
peerTaskManager peer.TaskManager
|
||||||
storageManager storage.Manager
|
storageManager storage.Manager
|
||||||
defaultPattern commonv1.Pattern
|
|
||||||
|
|
||||||
downloadServer *grpc.Server
|
downloadServer *grpc.Server
|
||||||
peerServer *grpc.Server
|
peerServer *grpc.Server
|
||||||
|
|
@ -96,15 +95,13 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(peerHost *schedulerv1.PeerHost, peerTaskManager peer.TaskManager,
|
func New(peerHost *schedulerv1.PeerHost, peerTaskManager peer.TaskManager,
|
||||||
storageManager storage.Manager, defaultPattern commonv1.Pattern,
|
storageManager storage.Manager, recursiveConcurrent int, cacheRecursiveMetadata time.Duration,
|
||||||
recursiveConcurrent int, cacheRecursiveMetadata time.Duration,
|
|
||||||
downloadOpts []grpc.ServerOption, peerOpts []grpc.ServerOption) (Server, error) {
|
downloadOpts []grpc.ServerOption, peerOpts []grpc.ServerOption) (Server, error) {
|
||||||
s := &server{
|
s := &server{
|
||||||
KeepAlive: util.NewKeepAlive("rpc server"),
|
KeepAlive: util.NewKeepAlive("rpc server"),
|
||||||
peerHost: peerHost,
|
peerHost: peerHost,
|
||||||
peerTaskManager: peerTaskManager,
|
peerTaskManager: peerTaskManager,
|
||||||
storageManager: storageManager,
|
storageManager: storageManager,
|
||||||
defaultPattern: defaultPattern,
|
|
||||||
|
|
||||||
recursiveConcurrent: recursiveConcurrent,
|
recursiveConcurrent: recursiveConcurrent,
|
||||||
cacheRecursiveMetadata: cacheRecursiveMetadata,
|
cacheRecursiveMetadata: cacheRecursiveMetadata,
|
||||||
|
|
@ -443,7 +440,6 @@ func (s *server) recursiveDownloadWithP2PMetadata(
|
||||||
URL: purl.String(),
|
URL: purl.String(),
|
||||||
URLMeta: &urlMeta,
|
URLMeta: &urlMeta,
|
||||||
PeerID: idgen.PeerID(s.peerHost.Ip),
|
PeerID: idgen.PeerID(s.peerHost.Ip),
|
||||||
Pattern: config.ConvertPattern(req.Pattern, s.defaultPattern),
|
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("start stream task for metadata error: %s", err)
|
log.Errorf("start stream task for metadata error: %s", err)
|
||||||
|
|
@ -656,8 +652,6 @@ func copyDownRequest(req *dfdaemonv1.DownRequest) *dfdaemonv1.DownRequest {
|
||||||
Limit: req.Limit,
|
Limit: req.Limit,
|
||||||
DisableBackSource: req.DisableBackSource,
|
DisableBackSource: req.DisableBackSource,
|
||||||
UrlMeta: req.UrlMeta,
|
UrlMeta: req.UrlMeta,
|
||||||
Pattern: req.Pattern,
|
|
||||||
Callsystem: req.Callsystem,
|
|
||||||
Uid: req.Uid,
|
Uid: req.Uid,
|
||||||
Gid: req.Gid,
|
Gid: req.Gid,
|
||||||
KeepOriginalOffset: req.KeepOriginalOffset,
|
KeepOriginalOffset: req.KeepOriginalOffset,
|
||||||
|
|
@ -700,12 +694,10 @@ func (s *server) download(ctx context.Context, req *dfdaemonv1.DownRequest, stre
|
||||||
UrlMeta: req.UrlMeta,
|
UrlMeta: req.UrlMeta,
|
||||||
PeerId: peerID,
|
PeerId: peerID,
|
||||||
PeerHost: s.peerHost,
|
PeerHost: s.peerHost,
|
||||||
Pattern: config.ConvertPattern(req.Pattern, s.defaultPattern),
|
|
||||||
},
|
},
|
||||||
Output: req.Output,
|
Output: req.Output,
|
||||||
Limit: req.Limit,
|
Limit: req.Limit,
|
||||||
DisableBackSource: req.DisableBackSource,
|
DisableBackSource: req.DisableBackSource,
|
||||||
Callsystem: req.Callsystem,
|
|
||||||
KeepOriginalOffset: req.KeepOriginalOffset,
|
KeepOriginalOffset: req.KeepOriginalOffset,
|
||||||
}
|
}
|
||||||
if len(req.UrlMeta.Range) > 0 {
|
if len(req.UrlMeta.Range) > 0 {
|
||||||
|
|
@ -959,8 +951,6 @@ func (s *server) exportFromPeers(ctx context.Context, log *logger.SugaredLoggerO
|
||||||
Limit: req.Limit,
|
Limit: req.Limit,
|
||||||
DisableBackSource: true,
|
DisableBackSource: true,
|
||||||
UrlMeta: req.UrlMeta,
|
UrlMeta: req.UrlMeta,
|
||||||
Pattern: "",
|
|
||||||
Callsystem: req.Callsystem,
|
|
||||||
Uid: req.Uid,
|
Uid: req.Uid,
|
||||||
Gid: req.Gid,
|
Gid: req.Gid,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,10 +71,9 @@ func TestServer_New(t *testing.T) {
|
||||||
mockpeerHost := &schedulerv1.PeerHost{}
|
mockpeerHost := &schedulerv1.PeerHost{}
|
||||||
mockpeerTaskManager := peer.NewMockTaskManager(ctrl)
|
mockpeerTaskManager := peer.NewMockTaskManager(ctrl)
|
||||||
mockStorageManger := mocks.NewMockManager(ctrl)
|
mockStorageManger := mocks.NewMockManager(ctrl)
|
||||||
var defaultPattern commonv1.Pattern = 0
|
|
||||||
var mockdownloadOpts []grpc.ServerOption
|
var mockdownloadOpts []grpc.ServerOption
|
||||||
var mockpeerOpts []grpc.ServerOption
|
var mockpeerOpts []grpc.ServerOption
|
||||||
_, err := New(mockpeerHost, mockpeerTaskManager, mockStorageManger, defaultPattern, 16, 0, mockdownloadOpts, mockpeerOpts)
|
_, err := New(mockpeerHost, mockpeerTaskManager, mockStorageManger, 16, 0, mockdownloadOpts, mockpeerOpts)
|
||||||
tc.expect(t, err)
|
tc.expect(t, err)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -216,7 +215,6 @@ func TestServer_ExportTask(t *testing.T) {
|
||||||
UrlMeta: &commonv1.UrlMeta{
|
UrlMeta: &commonv1.UrlMeta{
|
||||||
Tag: "unit test",
|
Tag: "unit test",
|
||||||
},
|
},
|
||||||
Callsystem: "",
|
|
||||||
},
|
},
|
||||||
mock: func(mockStorageManger *mocks.MockManagerMockRecorder, mockTaskManager *peer.MockTaskManagerMockRecorder, mocktsd *mocks.MockTaskStorageDriver, mockPieceManager *peer.MockPieceManager) {
|
mock: func(mockStorageManger *mocks.MockManagerMockRecorder, mockTaskManager *peer.MockTaskManagerMockRecorder, mocktsd *mocks.MockTaskStorageDriver, mockPieceManager *peer.MockPieceManager) {
|
||||||
mockStorageManger.FindCompletedTask(gomock.Any()).Return(nil)
|
mockStorageManger.FindCompletedTask(gomock.Any()).Return(nil)
|
||||||
|
|
@ -690,8 +688,6 @@ func TestServer_ServeDownload(t *testing.T) {
|
||||||
UrlMeta: &commonv1.UrlMeta{
|
UrlMeta: &commonv1.UrlMeta{
|
||||||
Tag: "unit test",
|
Tag: "unit test",
|
||||||
},
|
},
|
||||||
Pattern: "p2p",
|
|
||||||
Callsystem: "",
|
|
||||||
}
|
}
|
||||||
down, err := client.Download(context.Background(), request)
|
down, err := client.Download(context.Background(), request)
|
||||||
assert.Nil(err, "client download grpc call should be ok")
|
assert.Nil(err, "client download grpc call should be ok")
|
||||||
|
|
|
||||||
|
|
@ -74,9 +74,8 @@ func (s *seeder) ObtainSeeds(seedRequest *cdnsystemv1.SeedRequest, seedsServer c
|
||||||
HostLoad: nil,
|
HostLoad: nil,
|
||||||
IsMigrating: false,
|
IsMigrating: false,
|
||||||
},
|
},
|
||||||
Limit: 0,
|
Limit: 0,
|
||||||
Callsystem: "",
|
Range: nil, // following code will update Range
|
||||||
Range: nil, // following code will update Range
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log := logger.With("peer", req.PeerId, "task", seedRequest.TaskId, "component", "seedService")
|
log := logger.With("peer", req.PeerId, "task", seedRequest.TaskId, "component", "seedService")
|
||||||
|
|
|
||||||
|
|
@ -72,9 +72,6 @@ type transport struct {
|
||||||
// defaultFilter is used when http request without X-Dragonfly-Filter Header
|
// defaultFilter is used when http request without X-Dragonfly-Filter Header
|
||||||
defaultFilter string
|
defaultFilter string
|
||||||
|
|
||||||
// defaultFilter is used for registering steam task
|
|
||||||
defaultPattern commonv1.Pattern
|
|
||||||
|
|
||||||
// defaultTag is used when http request without X-Dragonfly-Tag Header
|
// defaultTag is used when http request without X-Dragonfly-Tag Header
|
||||||
defaultTag string
|
defaultTag string
|
||||||
|
|
||||||
|
|
@ -133,14 +130,6 @@ func WithDefaultFilter(f string) Option {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithDefaultPattern sets default pattern
|
|
||||||
func WithDefaultPattern(pattern commonv1.Pattern) Option {
|
|
||||||
return func(rt *transport) *transport {
|
|
||||||
rt.defaultPattern = pattern
|
|
||||||
return rt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// WithDefaultTag sets default tag for http requests with X-Dragonfly-Tag Header
|
// WithDefaultTag sets default tag for http requests with X-Dragonfly-Tag Header
|
||||||
func WithDefaultTag(b string) Option {
|
func WithDefaultTag(b string) Option {
|
||||||
return func(rt *transport) *transport {
|
return func(rt *transport) *transport {
|
||||||
|
|
|
||||||
|
|
@ -242,7 +242,6 @@ func newDownRequest(cfg *config.DfgetConfig, hdr map[string]string) *dfdaemonv1.
|
||||||
Application: cfg.Application,
|
Application: cfg.Application,
|
||||||
Priority: commonv1.Priority(cfg.Priority),
|
Priority: commonv1.Priority(cfg.Priority),
|
||||||
},
|
},
|
||||||
Pattern: cfg.Pattern,
|
|
||||||
Uid: int64(os.Getuid()),
|
Uid: int64(os.Getuid()),
|
||||||
Gid: int64(os.Getgid()),
|
Gid: int64(os.Getgid()),
|
||||||
KeepOriginalOffset: cfg.KeepOriginalOffset,
|
KeepOriginalOffset: cfg.KeepOriginalOffset,
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,6 @@ func init() {
|
||||||
flags.StringP("cid", "i", "", "content or cache ID, e.g. sha256 digest of the content")
|
flags.StringP("cid", "i", "", "content or cache ID, e.g. sha256 digest of the content")
|
||||||
flags.StringP("tag", "t", "", "different tags for the same cid will be recognized as different files in P2P network")
|
flags.StringP("tag", "t", "", "different tags for the same cid will be recognized as different files in P2P network")
|
||||||
flags.Duration("timeout", dfcacheConfig.Timeout, "Timeout for this cache operation, 0 is infinite")
|
flags.Duration("timeout", dfcacheConfig.Timeout, "Timeout for this cache operation, 0 is infinite")
|
||||||
flags.String("callsystem", dfcacheConfig.CallSystem, "The caller name which is mainly used for statistics and access control")
|
|
||||||
flags.String("workhome", dfcacheConfig.WorkHome, "Dfcache working directory")
|
flags.String("workhome", dfcacheConfig.WorkHome, "Dfcache working directory")
|
||||||
flags.String("logdir", dfcacheConfig.LogDir, "Dfcache log directory")
|
flags.String("logdir", dfcacheConfig.LogDir, "Dfcache log directory")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,6 @@ import (
|
||||||
"d7y.io/dragonfly/v2/pkg/os/user"
|
"d7y.io/dragonfly/v2/pkg/os/user"
|
||||||
"d7y.io/dragonfly/v2/pkg/rpc/dfdaemon/client"
|
"d7y.io/dragonfly/v2/pkg/rpc/dfdaemon/client"
|
||||||
"d7y.io/dragonfly/v2/pkg/source"
|
"d7y.io/dragonfly/v2/pkg/source"
|
||||||
"d7y.io/dragonfly/v2/pkg/types"
|
|
||||||
"d7y.io/dragonfly/v2/pkg/unit"
|
"d7y.io/dragonfly/v2/pkg/unit"
|
||||||
"d7y.io/dragonfly/v2/version"
|
"d7y.io/dragonfly/v2/version"
|
||||||
)
|
)
|
||||||
|
|
@ -158,11 +157,6 @@ func init() {
|
||||||
flagSet.Bool("disable-back-source", dfgetConfig.DisableBackSource,
|
flagSet.Bool("disable-back-source", dfgetConfig.DisableBackSource,
|
||||||
"Disable downloading directly from source when the daemon fails to download file")
|
"Disable downloading directly from source when the daemon fails to download file")
|
||||||
|
|
||||||
flagSet.StringP("pattern", "p", dfgetConfig.Pattern, "The downloading pattern: p2p/seed-peer/source")
|
|
||||||
if err := flagSet.MarkDeprecated("pattern", "please use --priority instead"); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
flagSet.Int32P("priority", "P", dfgetConfig.Priority, "Scheduler will schedule task according to priority")
|
flagSet.Int32P("priority", "P", dfgetConfig.Priority, "Scheduler will schedule task according to priority")
|
||||||
|
|
||||||
flagSet.BoolP("show-progress", "b", dfgetConfig.ShowProgress, "Show progress bar, it conflicts with --console")
|
flagSet.BoolP("show-progress", "b", dfgetConfig.ShowProgress, "Show progress bar, it conflicts with --console")
|
||||||
|
|
@ -235,13 +229,11 @@ func runDfget(dfgetLockPath, daemonSockPath string) error {
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
if dfgetConfig.Pattern != types.SourcePattern {
|
logger.Info("start to check and spawn daemon")
|
||||||
logger.Info("start to check and spawn daemon")
|
if dfdaemonClient, err = checkAndSpawnDaemon(dfgetLockPath, daemonSockPath); err != nil {
|
||||||
if dfdaemonClient, err = checkAndSpawnDaemon(dfgetLockPath, daemonSockPath); err != nil {
|
logger.Errorf("check and spawn daemon error: %v", err)
|
||||||
logger.Errorf("check and spawn daemon error: %v", err)
|
} else {
|
||||||
} else {
|
logger.Info("check and spawn daemon success")
|
||||||
logger.Info("check and spawn daemon success")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return dfget.Download(dfgetConfig, dfdaemonClient)
|
return dfget.Download(dfgetConfig, dfdaemonClient)
|
||||||
|
|
|
||||||
6
go.mod
6
go.mod
|
|
@ -3,7 +3,7 @@ module d7y.io/dragonfly/v2
|
||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
require (
|
require (
|
||||||
d7y.io/api v1.3.9
|
d7y.io/api v1.4.0
|
||||||
github.com/RichardKnop/machinery v1.10.6
|
github.com/RichardKnop/machinery v1.10.6
|
||||||
github.com/Showmax/go-fqdn v1.0.0
|
github.com/Showmax/go-fqdn v1.0.0
|
||||||
github.com/VividCortex/mysqlerr v1.0.0
|
github.com/VividCortex/mysqlerr v1.0.0
|
||||||
|
|
@ -104,7 +104,7 @@ require (
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
|
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||||
github.com/envoyproxy/protoc-gen-validate v0.9.0 // indirect
|
github.com/envoyproxy/protoc-gen-validate v0.9.1 // indirect
|
||||||
github.com/fsnotify/fsnotify v1.5.4 // indirect
|
github.com/fsnotify/fsnotify v1.5.4 // indirect
|
||||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||||
github.com/go-echarts/go-echarts/v2 v2.2.4 // indirect
|
github.com/go-echarts/go-echarts/v2 v2.2.4 // indirect
|
||||||
|
|
@ -206,7 +206,7 @@ require (
|
||||||
golang.org/x/net v0.2.0 // indirect
|
golang.org/x/net v0.2.0 // indirect
|
||||||
golang.org/x/term v0.3.0 // indirect
|
golang.org/x/term v0.3.0 // indirect
|
||||||
golang.org/x/text v0.4.0 // indirect
|
golang.org/x/text v0.4.0 // indirect
|
||||||
golang.org/x/tools v0.2.0 // indirect
|
golang.org/x/tools v0.3.0 // indirect
|
||||||
google.golang.org/appengine v1.6.7 // indirect
|
google.golang.org/appengine v1.6.7 // indirect
|
||||||
google.golang.org/genproto v0.0.0-20221018160656-63c7b68cfc55 // indirect
|
google.golang.org/genproto v0.0.0-20221018160656-63c7b68cfc55 // indirect
|
||||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||||
|
|
|
||||||
14
go.sum
14
go.sum
|
|
@ -69,8 +69,8 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX
|
||||||
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
|
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
|
||||||
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
|
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
|
||||||
cloud.google.com/go/storage v1.22.1/go.mod h1:S8N1cAStu7BOeFfE8KAQzmyyLkK8p/vmRq6kuBTW58Y=
|
cloud.google.com/go/storage v1.22.1/go.mod h1:S8N1cAStu7BOeFfE8KAQzmyyLkK8p/vmRq6kuBTW58Y=
|
||||||
d7y.io/api v1.3.9 h1:u5HgSTLDz/hMtDN4Ha9JI6KKFfBOfBbSe2nd+Cz94Tc=
|
d7y.io/api v1.4.0 h1:KXjKfHpqZdy+kuwK7vo1WA2kHApaZnqwO5xWsPtkI80=
|
||||||
d7y.io/api v1.3.9/go.mod h1:HERD+sbavL0vJXkd37RZxJvpu+nXZ6ipffm4EFUbF2w=
|
d7y.io/api v1.4.0/go.mod h1:nxtfwYYTCN7Mvx79lLk8xUfvldIUDyzYIfgOmyln+8M=
|
||||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20201218220906-28db891af037/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
dmitri.shuralyov.com/gpu/mtl v0.0.0-20201218220906-28db891af037/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U=
|
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U=
|
||||||
|
|
@ -255,8 +255,8 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.m
|
||||||
github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0=
|
github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0=
|
||||||
github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE=
|
github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE=
|
||||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||||
github.com/envoyproxy/protoc-gen-validate v0.9.0 h1:wyv+mWIshClA4g6hTlKD9xb6fiNAnDu3+8qYf7KSuSE=
|
github.com/envoyproxy/protoc-gen-validate v0.9.1 h1:PS7VIOgmSVhWUEeZwTe7z7zouA22Cr590PzXKbZHOVY=
|
||||||
github.com/envoyproxy/protoc-gen-validate v0.9.0/go.mod h1:aUb/JIPT9p8VQ1hMxCrB3/NZSvKoF7fPIE1ULgCIVz0=
|
github.com/envoyproxy/protoc-gen-validate v0.9.1/go.mod h1:OKNgG7TCp5pF4d6XftA0++PMirau2/yoOwVac3AbF2w=
|
||||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||||
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
|
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
|
||||||
github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=
|
github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=
|
||||||
|
|
@ -1291,7 +1291,7 @@ golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.5.1-0.20210830214625-1b1db11ec8f4/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
|
golang.org/x/mod v0.5.1-0.20210830214625-1b1db11ec8f4/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
|
||||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||||
golang.org/x/mod v0.6.0 h1:b9gGHsz9/HhJ3HF5DHQytPpuwocVTChQJK3AvoLRD5I=
|
golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA=
|
||||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
|
@ -1601,8 +1601,8 @@ golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||||
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||||
golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
|
golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
|
||||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||||
golang.org/x/tools v0.2.0 h1:G6AHpWxTMGY1KyEYoAQ5WTtIekUUvDNjan3ugu60JvE=
|
golang.org/x/tools v0.3.0 h1:SrNbZl6ECOS1qFzgTdQfWXZM9XBkiA6tkFrH9YSTPHM=
|
||||||
golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA=
|
golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k=
|
||||||
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
|
|
||||||
|
|
@ -39,17 +39,6 @@ const (
|
||||||
DfstoreName = "dfstore"
|
DfstoreName = "dfstore"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
// SourcePattern is back-to-source download pattern.
|
|
||||||
SourcePattern = "source"
|
|
||||||
|
|
||||||
// SeedPeerPattern is seed peer download pattern.
|
|
||||||
SeedPeerPattern = "seed-peer"
|
|
||||||
|
|
||||||
// P2PPattern is p2p download pattern.
|
|
||||||
P2PPattern = "p2p"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// MetricsNamespace is namespace of metrics.
|
// MetricsNamespace is namespace of metrics.
|
||||||
MetricsNamespace = "dragonfly"
|
MetricsNamespace = "dragonfly"
|
||||||
|
|
|
||||||
|
|
@ -69,8 +69,6 @@ func main() {
|
||||||
"awsS3ForcePathStyle": "true",
|
"awsS3ForcePathStyle": "true",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Pattern: "",
|
|
||||||
Callsystem: "",
|
|
||||||
Uid: 1000, // target uid
|
Uid: 1000, // target uid
|
||||||
Gid: 1000, // target gid
|
Gid: 1000, // target gid
|
||||||
KeepOriginalOffset: false,
|
KeepOriginalOffset: false,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue