/
option.go
88 lines (72 loc) · 2.26 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package client
import "github.com/pachyderm/pachyderm/v2/src/pfs"
type putFileConfig struct {
datum string
append bool
importConcurrency uint32
}
// PutFileOption configures a PutFile call.
type PutFileOption func(*putFileConfig)
// WithAppendPutFile configures the PutFile call to append to existing files.
func WithAppendPutFile() PutFileOption {
return func(pf *putFileConfig) {
pf.append = true
}
}
// WithDatumPutFile configures the PutFile call to apply to a particular datum.
func WithDatumPutFile(datum string) PutFileOption {
return func(pf *putFileConfig) {
pf.datum = datum
}
}
// WithImportConcurrency configures the maximum number of tasks in flight created by PutFileURL.
func WithImportConcurrency(importConcurrency uint32) PutFileOption {
return func(pf *putFileConfig) {
pf.importConcurrency = importConcurrency
}
}
type deleteFileConfig struct {
datum string
recursive bool
}
// DeleteFileOption configures a DeleteFile call.
type DeleteFileOption func(*deleteFileConfig)
// WithDatumDeleteFile configures the DeleteFile call to apply to a particular datum.
func WithDatumDeleteFile(datum string) DeleteFileOption {
return func(dfc *deleteFileConfig) {
dfc.datum = datum
}
}
// WithRecursiveDeleteFile configures the DeleteFile call to recursively delete the files in a directory.
func WithRecursiveDeleteFile() DeleteFileOption {
return func(dfc *deleteFileConfig) {
dfc.recursive = true
}
}
// CopyFileOption configures a CopyFile call.
type CopyFileOption func(*pfs.CopyFile)
// WithAppendCopyFile configures the CopyFile call to append to existing files.
func WithAppendCopyFile() CopyFileOption {
return func(cf *pfs.CopyFile) {
cf.Append = true
}
}
// WithDatumCopyFile configures the CopyFile call to apply to a particular datum.
func WithDatumCopyFile(datum string) CopyFileOption {
return func(cf *pfs.CopyFile) {
cf.Datum = datum
}
}
// GetFileOption configures a GetFile call
type GetFileOption func(*pfs.GetFileRequest)
// WithDatumGetFile sets the datum for the get file request
func WithDatumGetFile(datum string) GetFileOption {
return func(gf *pfs.GetFileRequest) {
gf.File.Datum = datum
}
}
func WithOffset(offset int64) GetFileOption {
return func(gf *pfs.GetFileRequest) {
gf.Offset = offset
}
}