MCPcopy
hub / github.com/rclone/rclone / New

Function New

lib/pacer/pacer.go:79–104  ·  view source on GitHub ↗

New returns a Pacer with sensible defaults.

(options ...Option)

Source from the content-addressed store, hash-verified

77
78// New returns a Pacer with sensible defaults.
79func New(options ...Option) *Pacer {
80 opts := pacerOptions{
81 maxConnections: 0,
82 retries: 3,
83 }
84 for _, o := range options {
85 o(&opts)
86 }
87 p := &Pacer{
88 pacerOptions: opts,
89 pacer: make(chan struct{}, 1),
90 }
91 if p.calculator == nil {
92 p.SetCalculator(nil)
93 }
94 p.state.SleepTime = p.calculator.Calculate(p.state)
95 if p.invoker == nil {
96 p.invoker = invoke
97 }
98 p.SetMaxConnections(p.maxConnections)
99
100 // Put the first pacing token in
101 p.pacer <- struct{}{}
102
103 return p
104}
105
106// SetMaxConnections sets the maximum number of concurrent connections.
107// Setting the value to 0 will allow unlimited number of connections.

Callers 15

NewFsFunction · 0.92
NewFsFunction · 0.92
NewPacerFunction · 0.92
TestNewFunction · 0.70
TestMaxConnectionsFunction · 0.70
TestSetRetriesFunction · 0.70
TestBeginCallFunction · 0.70
TestEndCallFunction · 0.70
TestCallFixedFunction · 0.70
Test_callRetryFunction · 0.70

Calls 3

SetCalculatorMethod · 0.95
SetMaxConnectionsMethod · 0.95
CalculateMethod · 0.65

Tested by 13

TestNewFunction · 0.56
TestMaxConnectionsFunction · 0.56
TestSetRetriesFunction · 0.56
TestBeginCallFunction · 0.56
TestEndCallFunction · 0.56
TestCallFixedFunction · 0.56
Test_callRetryFunction · 0.56
TestCallFunction · 0.56
TestCallParallelFunction · 0.56