/
client.go
45 lines (36 loc) · 1.7 KB
/
client.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
package pfsload
import (
"context"
"github.com/pachyderm/pachyderm/v2/src/internal/client"
"github.com/pachyderm/pachyderm/v2/src/pfs"
)
// Client is the standard interface for a load testing client.
// TODO: This should become the client.Client interface when we put the standard pach client behind an interface that
// takes a context as the first parameter for each method.
type Client interface {
WithCreateFileSetClient(ctx context.Context, cb func(client.ModifyFile) error) (*pfs.CreateFileSetResponse, error)
AddFileSet(ctx context.Context, commit *pfs.Commit, ID string) error
GlobFile(ctx context.Context, commit *pfs.Commit, pattern string, cb func(*pfs.FileInfo) error) error
WaitCommitSet(ctx context.Context, id string, cb func(*pfs.CommitInfo) error) error
}
type pachClient struct {
pfs pfs.APIClient
}
func NewPachClient(pfs pfs.APIClient) Client {
return &pachClient{pfs: pfs}
}
func (pc *pachClient) WithCreateFileSetClient(ctx context.Context, cb func(client.ModifyFile) error) (*pfs.CreateFileSetResponse, error) {
return client.WithCreateFileSetClient(ctx, pc.pfs, cb)
}
func (pc *pachClient) AddFileSet(ctx context.Context, commit *pfs.Commit, filesetID string) error {
project := commit.Repo.Project.GetName()
repo := commit.Repo.Name
branch := commit.Branch.Name
return client.AddFileSet(ctx, pc.pfs, project, repo, branch, commit.Id, filesetID)
}
func (pc *pachClient) GlobFile(ctx context.Context, commit *pfs.Commit, pattern string, cb func(*pfs.FileInfo) error) error {
return client.GlobFile(ctx, pc.pfs, commit, pattern, cb)
}
func (pc *pachClient) WaitCommitSet(ctx context.Context, id string, cb func(*pfs.CommitInfo) error) error {
return client.WaitCommitSet(ctx, pc.pfs, id, cb)
}