當前位置: 首頁>>代碼示例>>Golang>>正文


Golang JobServer.AddWorkUnits方法代碼示例

本文整理匯總了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)
	}
}
開發者ID:diffeo,項目名稱:go-coordinate,代碼行數:12,代碼來源:python_test.go

示例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)
	}
}
開發者ID:diffeo,項目名稱:go-coordinate,代碼行數:18,代碼來源:python_test.go

示例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)
	}
}
開發者ID:diffeo,項目名稱:go-coordinate,代碼行數:15,代碼來源:python_test.go


注:本文中的github.com/diffeo/go-coordinate/jobserver.JobServer.AddWorkUnits方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。