本文整理匯總了Golang中github.com/tsuru/monsterqueue.Job.Queue方法的典型用法代碼示例。如果您正苦於以下問題:Golang Job.Queue方法的具體用法?Golang Job.Queue怎麽用?Golang Job.Queue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/tsuru/monsterqueue.Job
的用法示例。
在下文中一共展示了Job.Queue方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Run
func (t *machineCreate) Run(job monsterqueue.Job) {
params := job.Parameters()
jobId := params["jobId"].(string)
vmId := params["vmId"].(string)
projectId := params["projectId"].(string)
ip, err := t.iaas.waitVMIsCreated(jobId, vmId, projectId)
if err != nil {
_, qErr := job.Queue().Enqueue(t.iaas.taskName(machineDeleteTaskName), monsterqueue.JobParams{
"vmId": vmId,
"projectId": projectId,
})
if qErr != nil {
job.Error(fmt.Errorf("error trying to enqueue deletion: %s caused by: %s", qErr, err))
return
}
job.Error(err)
return
}
if tags, ok := params["tags"]; ok {
var cloudTags []*cloudstackTag
tagList := strings.Split(tags.(string), ",")
cloudTags = make([]*cloudstackTag, 0, len(tagList))
for _, tag := range tagList {
if strings.Contains(tag, ":") {
parts := strings.SplitN(tag, ":", 2)
cloudTags = append(cloudTags, &cloudstackTag{
Key: string(parts[0]),
Value: string(parts[1]),
})
}
}
if len(cloudTags) > 0 {
param := make(map[string]string)
param["resourceids"] = vmId
param["resourcetype"] = "UserVm"
for index, tag := range cloudTags {
param["tags["+strconv.Itoa(index+1)+"].key"] = tag.Key
param["tags["+strconv.Itoa(index+1)+"].value"] = tag.Value
}
param["projectId"] = projectId
var result CreateTagsResponse
err = t.iaas.do("createTags", param, &result)
if err != nil {
job.Error(err)
return
}
}
}
notified, _ := job.Success(ip)
if !notified {
_, err = job.Queue().Enqueue(t.iaas.taskName(machineDeleteTaskName), monsterqueue.JobParams{
"vmId": vmId,
"projectId": projectId,
})
if err != nil {
log.Errorf("could not enqueue delete unnotified vm: %s", err)
return
}
}
}
示例2: Run
func (t *machineCreate) Run(job monsterqueue.Job) {
params := job.Parameters()
jobId := params["jobId"].(string)
vmId := params["vmId"].(string)
projectId := params["projectId"].(string)
ip, err := t.iaas.waitVMIsCreated(jobId, vmId, projectId)
if err != nil {
_, qErr := job.Queue().Enqueue(t.iaas.taskName(machineDeleteTaskName), monsterqueue.JobParams{
"vmId": vmId,
"projectId": projectId,
})
if qErr != nil {
job.Error(fmt.Errorf("error trying to enqueue deletion: %s caused by: %s", qErr, err))
return
}
job.Error(err)
return
}
notified, _ := job.Success(ip)
if !notified {
_, err = job.Queue().Enqueue(t.iaas.taskName(machineDeleteTaskName), monsterqueue.JobParams{
"vmId": vmId,
"projectId": projectId,
})
if err != nil {
log.Errorf("could not enqueue delete unnotified vm: %s", err)
return
}
}
}