本文整理汇总了Golang中github.com/diffeo/go-coordinate/jobserver.JobServer.AddWorkUnits方法的典型用法代码示例。如果您正苦于以下问题:Golang JobServer.AddWorkUnits方法的具体用法?Golang JobServer.AddWorkUnits怎么用?Golang JobServer.AddWorkUnits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/diffeo/go-coordinate/jobserver.JobServer
的用法示例。
在下文中一共展示了JobServer.AddWorkUnits方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: addWorkUnit
// addWorkUnit packages a single work unit key and data dictionary
// into the tuple format JobServer expects, and calls AddWorkUnits(),
// checking the result.
func addWorkUnit(t *testing.T, j *jobserver.JobServer, workSpecName, key string, data map[string]interface{}) {
keyDataPair := cborrpc.PythonTuple{Items: []interface{}{key, data}}
keyDataList := []interface{}{keyDataPair}
ok, msg, err := j.AddWorkUnits(workSpecName, keyDataList)
if assert.NoError(t, err) {
assert.True(t, ok)
assert.Empty(t, msg)
}
}
示例2: addPrefixedWorkUnits
// addPrefixedWorkUnits adds a series of similarly-named work units
// to a work spec. If prefix is "u", it adds count work units named
// u001, u002, .... The work spec dictionaries have a single key "k"
// with values v1, v2, ....
func addPrefixedWorkUnits(t *testing.T, j *jobserver.JobServer, workSpecName, prefix string, count int) {
workUnitKvps := make([]interface{}, count)
for i := range workUnitKvps {
key := fmt.Sprintf("%s%03d", prefix, i+1)
data := map[string]interface{}{"k": fmt.Sprintf("v%v", i+1)}
items := []interface{}{key, data}
workUnitKvps[i] = cborrpc.PythonTuple{Items: items}
}
ok, msg, err := j.AddWorkUnits(workSpecName, workUnitKvps)
if assert.NoError(t, err) {
assert.True(t, ok)
assert.Empty(t, msg)
}
}
示例3: addWorkUnits
// addWorkUnits adds a batch of work units to the system in one call.
func addWorkUnits(t *testing.T, j *jobserver.JobServer, workSpecName string, workUnits map[string]map[string]interface{}) {
// Assemble the parameters to AddWorkUnits as one big list of
// pairs of (key, data)
var awu []interface{}
for name, data := range workUnits {
pair := []interface{}{name, data}
awu = append(awu, pair)
}
ok, msg, err := j.AddWorkUnits(workSpecName, awu)
if assert.NoError(t, err) {
assert.True(t, ok)
assert.Empty(t, msg)
}
}