本文整理汇总了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
}