Skip to content

Commit 6f078bc

Browse files
authored
Migrated resume code (#3289)
1 parent 77d4cf3 commit 6f078bc

21 files changed

+1278
-921
lines changed

azcopy/client.go

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,40 @@ const (
3535
oauthLoginSessionCacheAccountName = "AzCopyOAuthTokenCache"
3636
)
3737

38+
const (
39+
// Base10Mega For networking throughput in Mbps, (and only for networking), we divide by 1000*1000 (not 1024 * 1024) because
40+
// networking is traditionally done in base 10 units (not base 2).
41+
// E.g. "gigabit ethernet" means 10^9 bits/sec, not 2^30. So by using base 10 units
42+
// we give the best correspondence to the sizing of the user's network pipes.
43+
// See https://networkengineering.stackexchange.com/questions/3628/iec-or-si-units-binary-prefixes-used-for-network-measurement
44+
// NOTE that for everything else in the app (e.g. sizes of files) we use the base 2 units (i.e. 1024 * 1024) because
45+
// for RAM and disk file sizes, it is conventional to use the power-of-two-based units.
46+
Base10Mega = 1000 * 1000
47+
)
48+
49+
// It's not pretty that this one is read directly by credential util.
50+
// But doing otherwise required us passing it around in many places, even though really
51+
// it can be thought of as an "ambient" property. That's the (weak?) justification for implementing
52+
// it as a global
53+
var TrustedSuffixes string
54+
3855
type Client struct {
3956
CurrentJobID common.JobID // TODO (gapra): In future this should only be set when there is a current job running. On complete, this should be cleared. It can also behave as something we can check to see if a current job is running
4057
oauthTokenManager *common.UserOAuthTokenManager // OAuth token manager for the current user, used for authentication
58+
logLevel common.LogLevel
4159
}
4260

4361
type ClientOptions struct {
44-
CapMbps float64
62+
CapMbps float64
63+
TrustedSuffixes string
64+
LogLevel *common.LogLevel
4565
}
4666

4767
func NewClient(opts ClientOptions) (Client, error) {
48-
c := Client{}
68+
c := Client{
69+
logLevel: common.IffNil(opts.LogLevel, common.ELogLevel.Info()), // Default: Info
70+
}
71+
TrustedSuffixes = opts.TrustedSuffixes
4972
common.InitializeFolders()
5073
configureGoMaxProcs()
5174
// Perform os specific initialization
@@ -81,6 +104,11 @@ func (c *Client) GetUserOAuthTokenManagerInstance() *common.UserOAuthTokenManage
81104
return c.oauthTokenManager
82105
}
83106

107+
// GetLogLevel returns the log level of the client.
108+
func (c *Client) GetLogLevel() common.LogLevel {
109+
return c.logLevel
110+
}
111+
84112
// Ensure we always have more than 1 OS thread running goroutines, since there are issues with having just 1.
85113
// (E.g. version check doesn't happen at login time, if have only one go proc. Not sure why that happens if have only one
86114
// proc. Is presumably due to the high CPU usage we see on login if only 1 CPU, even tho can't see any busy-wait in that code)
@@ -90,3 +118,9 @@ func configureGoMaxProcs() {
90118
runtime.GOMAXPROCS(2)
91119
}
92120
}
121+
122+
// JobContext contains initialization context for a job.
123+
type JobContext struct {
124+
JobID common.JobID
125+
LogPath string
126+
}

0 commit comments

Comments
 (0)