/
option.go
71 lines (59 loc) · 1.44 KB
/
option.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package datum
import (
"context"
"fmt"
"time"
"github.com/pachyderm/pachyderm/v2/src/internal/client"
)
// SetOption configures a set.
type SetOption func(*Set)
// WithMetaOutput sets the Client for the meta output.
func WithMetaOutput(mf client.ModifyFile) SetOption {
return func(s *Set) {
s.metaOutputClient = mf
}
}
// WithPFSOutput sets the Client for the pfs output.
func WithPFSOutput(mf client.ModifyFile) SetOption {
return func(s *Set) {
s.pfsOutputClient = mf
}
}
// WithStats sets the stats to fill in.
func WithStats(stats *Stats) SetOption {
return func(s *Set) {
s.stats = stats
}
}
// Option configures a datum.
type Option func(*Datum)
// WithRetry sets the number of retries.
func WithRetry(numRetries int) Option {
return func(d *Datum) {
d.numRetries = numRetries
}
}
// WithRecoveryCallback sets the recovery callback.
func WithRecoveryCallback(cb func(context.Context) error) Option {
return func(d *Datum) {
d.recoveryCallback = cb
}
}
// WithTimeout sets the timeout.
func WithTimeout(timeout time.Duration) Option {
return func(d *Datum) {
d.timeout = timeout
}
}
// WithPrefixIndex prefixes the datum directory name (both locally and in PFS) with its index value.
func WithPrefixIndex() Option {
return func(d *Datum) {
d.IDPrefix = fmt.Sprintf("%032d", d.meta.Index) + "-"
}
}
// WithEnv sets the environment variables.
func WithEnv(env []string) Option {
return func(d *Datum) {
d.env = env
}
}