本文整理匯總了Golang中github.com/tsuru/monsterqueue.Job.Result方法的典型用法代碼示例。如果您正苦於以下問題:Golang Job.Result方法的具體用法?Golang Job.Result怎麽用?Golang Job.Result使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/tsuru/monsterqueue.Job
的用法示例。
在下文中一共展示了Job.Result方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: AddNode
func (p *dockerProvisioner) AddNode(opts provision.AddNodeOptions) error {
node := cluster.Node{
Address: opts.Address,
Metadata: opts.Metadata,
CreationStatus: cluster.NodeCreationStatusPending,
CaCert: opts.CaCert,
ClientCert: opts.ClientCert,
ClientKey: opts.ClientKey,
}
if len(opts.CaCert) == 0 && len(p.caCert) > 0 {
node.CaCert = p.caCert
node.ClientCert = p.clientCert
node.ClientKey = p.clientKey
}
err := p.Cluster().Register(node)
if err != nil {
return err
}
q, err := queue.Queue()
if err != nil {
return err
}
jobParams := monsterqueue.JobParams{"endpoint": opts.Address, "metadata": opts.Metadata}
var job monsterqueue.Job
if opts.WaitTO != 0 {
job, err = q.EnqueueWait(internalNodeContainer.QueueTaskName, jobParams, opts.WaitTO)
} else {
_, err = q.Enqueue(internalNodeContainer.QueueTaskName, jobParams)
}
if err == nil && job != nil {
_, err = job.Result()
}
return err
}
示例2: addNode
func (a *autoScaleConfig) addNode(event *autoScaleEvent, modelNodes []*cluster.Node) (*cluster.Node, error) {
metadata, err := chooseMetadataFromNodes(modelNodes)
if err != nil {
return nil, err
}
_, hasIaas := metadata["iaas"]
if !hasIaas {
return nil, fmt.Errorf("no IaaS information in nodes metadata: %#v", metadata)
}
machine, err := iaas.CreateMachineForIaaS(metadata["iaas"], metadata)
if err != nil {
return nil, fmt.Errorf("unable to create machine: %s", err.Error())
}
newAddr := machine.FormatNodeAddress()
event.logMsg("new machine created: %s - Waiting for docker to start...", newAddr)
createdNode := cluster.Node{
Address: newAddr,
Metadata: metadata,
CreationStatus: cluster.NodeCreationStatusPending,
}
err = a.provisioner.Cluster().Register(createdNode)
if err != nil {
machine.Destroy()
return nil, fmt.Errorf("error registering new node %s: %s", newAddr, err.Error())
}
q, err := queue.Queue()
if err == nil {
jobParams := monsterqueue.JobParams{
"endpoint": createdNode.Address,
"machine": machine.Id,
"metadata": createdNode.Metadata,
}
var job monsterqueue.Job
job, err = q.EnqueueWait(bs.QueueTaskName, jobParams, a.WaitTimeNewMachine)
if err == nil {
_, err = job.Result()
}
}
if err != nil {
machine.Destroy()
a.provisioner.Cluster().Unregister(newAddr)
return nil, fmt.Errorf("error running bs task: %s", err)
}
event.logMsg("new machine created: %s - started!", newAddr)
return &createdNode, nil
}