本文整理匯總了Golang中github.com/tsuru/docker-cluster/cluster.Node.Metadata方法的典型用法代碼示例。如果您正苦於以下問題:Golang Node.Metadata方法的具體用法?Golang Node.Metadata怎麽用?Golang Node.Metadata使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/tsuru/docker-cluster/cluster.Node
的用法示例。
在下文中一共展示了Node.Metadata方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Run
func (t *runBs) Run(job monsterqueue.Job) {
params := job.Parameters()
dockerEndpoint := params["endpoint"].(string)
machineID := params["machine"].(string)
node := cluster.Node{Address: dockerEndpoint}
err := t.waitDocker(dockerEndpoint)
if err != nil {
job.Error(err)
t.destroyMachine(machineID)
return
}
rawMetadata := params["metadata"].(monsterqueue.JobParams)
metadata := make(map[string]string, len(rawMetadata))
for key, value := range rawMetadata {
metadata[key] = value.(string)
}
err = CreateContainer(dockerEndpoint, metadata["pool"], t.provisioner, true)
if err != nil {
node.CreationStatus = cluster.NodeCreationStatusError
node.Metadata = map[string]string{"creationError": err.Error()}
t.provisioner.Cluster().UpdateNode(node)
job.Error(err)
t.destroyMachine(machineID)
return
}
node.CreationStatus = cluster.NodeCreationStatusCreated
_, err = t.provisioner.Cluster().UpdateNode(node)
if err != nil {
job.Error(err)
t.destroyMachine(machineID)
return
}
job.Success(nil)
}
示例2: Run
func (t *runBs) Run(job monsterqueue.Job) {
params := job.Parameters()
dockerEndpoint := params["endpoint"].(string)
node := cluster.Node{Address: dockerEndpoint}
err := t.waitDocker(dockerEndpoint)
if err != nil {
job.Error(err)
return
}
node.CreationStatus = cluster.NodeCreationStatusCreated
rawMetadata := params["metadata"].(monsterqueue.JobParams)
metadata := make(map[string]string, len(rawMetadata))
for key, value := range rawMetadata {
metadata[key] = value.(string)
}
err = createContainer(dockerEndpoint, metadata["pool"], t.provisioner, true)
if err != nil {
t.provisioner.Cluster().UpdateNode(node)
job.Error(err)
return
}
node.Metadata = map[string]string{"LastSuccess": time.Now().Format(time.RFC3339)}
_, err = t.provisioner.Cluster().UpdateNode(node)
if err != nil {
job.Error(err)
return
}
job.Success(nil)
}
示例3: TestUpdateNodeDoesNotExist
func TestUpdateNodeDoesNotExist(t *testing.T) {
mongo, err := mongodb.Mongodb("mongodb://localhost:27017", "test-docker-node-update")
if err != nil {
t.Fatal(err)
}
clu, err := cluster.New(nil, mongo)
if err != nil {
t.Fatal(err)
}
node := cluster.Node{Address: "http://localhost:4243"}
err = clu.Register(node)
defer clu.Unregister("http://localhost:4243")
nodeUpd := cluster.Node{Address: "http://localhost:4223"}
nodeUpd.Metadata = map[string]string{"k1": "v1", "k2": "v2"}
nodeUpd, err = clu.UpdateNode(nodeUpd)
if err != storage.ErrNoSuchNode {
t.Error("Expected: No such node in storage, got: ", err)
}
}