本文整理汇总了Golang中github.com/pachyderm/pachyderm/src/pps.APIClient类的典型用法代码示例。如果您正苦于以下问题:Golang APIClient类的具体用法?Golang APIClient怎么用?Golang APIClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了APIClient类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: CreateJob
func CreateJob(
client pps.APIClient,
image string,
cmd []string,
stdin string,
shards uint64,
inputCommit []*pfs.Commit,
parentJobID string,
) (*pps.Job, error) {
var parentJob *pps.Job
if parentJobID != "" {
parentJob = NewJob(parentJobID)
}
return client.CreateJob(
context.Background(),
&pps.CreateJobRequest{
Transform: &pps.Transform{
Image: image,
Cmd: cmd,
Stdin: stdin,
},
Shards: shards,
InputCommit: inputCommit,
ParentJob: parentJob,
},
)
}
示例2: RunWorkload
func RunWorkload(
pfsClient pfs.APIClient,
ppsClient pps.APIClient,
rand *rand.Rand,
size int,
) error {
worker := newWorker(rand)
for i := 0; i < size; i++ {
if err := worker.work(pfsClient, ppsClient); err != nil {
return err
}
}
for _, job := range worker.startedJobs {
jobInfo, err := ppsClient.InspectJob(
context.Background(),
&pps.InspectJobRequest{
Job: job,
BlockState: true,
},
)
if err != nil {
return err
}
if jobInfo.State != pps.JobState_JOB_STATE_SUCCESS {
return fmt.Errorf("job %s failed", job.Id)
}
}
return nil
}
示例3: CreatePipeline
func CreatePipeline(
client pps.APIClient,
name string,
image string,
cmd []string,
stdin string,
shards uint64,
inputRepo []*pfs.Repo,
) error {
_, err := client.CreatePipeline(
context.Background(),
&pps.CreatePipelineRequest{
Pipeline: NewPipeline(name),
Transform: &pps.Transform{
Image: image,
Cmd: cmd,
Stdin: stdin,
},
Shards: shards,
InputRepo: inputRepo,
},
)
return err
}
示例4: work
func (w *worker) work(pfsClient pfs.APIClient, ppsClient pps.APIClient) error {
opt := w.rand.Float64()
switch {
case opt < repo:
repoName := w.randString(10)
if err := pfsutil.CreateRepo(pfsClient, repoName); err != nil {
return err
}
w.repos = append(w.repos, &pfs.Repo{Name: repoName})
commit, err := pfsutil.StartCommit(pfsClient, repoName, "")
if err != nil {
return err
}
w.started = append(w.started, commit)
case opt < commit:
if len(w.started) >= maxStartedCommits || len(w.finished) == 0 {
if len(w.started) == 0 {
return nil
}
i := w.rand.Intn(len(w.started))
commit := w.started[i]
if err := pfsutil.FinishCommit(pfsClient, commit.Repo.Name, commit.Id); err != nil {
return err
}
w.started = append(w.started[:i], w.started[i+1:]...)
w.finished = append(w.finished, commit)
} else {
if len(w.finished) == 0 {
return nil
}
commit := w.finished[w.rand.Intn(len(w.finished))]
commit, err := pfsutil.StartCommit(pfsClient, commit.Repo.Name, commit.Id)
if err != nil {
return err
}
w.started = append(w.started, commit)
}
case opt < file:
if len(w.started) == 0 {
return nil
}
commit := w.started[w.rand.Intn(len(w.started))]
if _, err := pfsutil.PutFile(pfsClient, commit.Repo.Name, commit.Id, w.randString(10), 0, w.reader()); err != nil {
return err
}
case opt < job:
if len(w.startedJobs) >= maxStartedJobs {
job := w.startedJobs[0]
w.startedJobs = w.startedJobs[1:]
jobInfo, err := ppsClient.InspectJob(
context.Background(),
&pps.InspectJobRequest{
Job: job,
BlockState: true,
},
)
if err != nil {
return err
}
if jobInfo.State != pps.JobState_JOB_STATE_SUCCESS {
return fmt.Errorf("job %s failed", job.Id)
}
w.jobs = append(w.jobs, job)
} else {
if len(w.finished) == 0 {
return nil
}
inputs := [5]string{}
var jobInputs []*pps.JobInput
repoSet := make(map[string]bool)
for i := range inputs {
commit := w.finished[w.rand.Intn(len(w.finished))]
if _, ok := repoSet[commit.Repo.Name]; ok {
continue
}
repoSet[commit.Repo.Name] = true
inputs[i] = commit.Repo.Name
jobInputs = append(jobInputs, &pps.JobInput{Commit: commit})
}
var parentJobID string
if len(w.jobs) > 0 {
parentJobID = w.jobs[w.rand.Intn(len(w.jobs))].Id
}
outFilename := w.randString(10)
job, err := ppsutil.CreateJob(
ppsClient,
"",
[]string{"bash"},
w.grepCmd(inputs, outFilename),
1,
jobInputs,
parentJobID,
)
if err != nil {
return err
}
w.startedJobs = append(w.startedJobs, job)
}
case opt < pipeline:
if len(w.repos) == 0 {
//.........这里部分代码省略.........