本文整理匯總了Golang中github.com/mikespook/gearman-go/worker.Job.Data方法的典型用法代碼示例。如果您正苦於以下問題:Golang Job.Data方法的具體用法?Golang Job.Data怎麽用?Golang Job.Data使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/mikespook/gearman-go/worker.Job
的用法示例。
在下文中一共展示了Job.Data方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Foobar
func Foobar(job worker.Job) ([]byte, error) {
log.Printf("Foobar: Data=[%s]\n", job.Data())
for i := 0; i < 10; i++ {
job.SendWarning([]byte{byte(i)})
job.SendData([]byte{byte(i)})
job.UpdateStatus(i+1, 100)
}
return job.Data(), nil
}
示例2: caffePlotTask
func caffePlotTask(job worker.Job) (data []byte, err error) {
suffix := string(job.Data())
if err = run(PLOT_ROOT+"/parse_log.sh", LOG_DIR+"/caffe.INFO"); err != nil {
log.Printf("Error: %s\n", err)
return
}
if err = run("gnuplot", PLOT_ROOT+"/plot_log.gnuplot."+suffix); err != nil {
log.Printf("Error: %s\n", err)
return
}
data, err = ioutil.ReadFile("/tmp/" + suffix + ".png")
return
}
示例3: DbUpsert
func DbUpsert(job worker.Job) ([]byte, error) {
// a gearman wrapper for UpsertDocument
dbhelp.Log(0, "Database upserter called!")
var data DbData
if err := bson.Unmarshal(job.Data(), &data); err != nil {
dbhelp.Log(2, err.Error())
return nil, err
}
if !dbhelp.CorrectKey(data.Key) {
dbhelp.Log(2, "Secret key mismatch")
b, _ := bson.Marshal(bson.M{"status": "error", "description": "Secret key mismatch"})
return b, job.Err()
}
url := dbhelp.GetURL()
response, err := UpsertDocument(url, data.Database, data.Collection, data.Data)
if err != nil {
dbhelp.Log(1, err.Error())
job.SendWarning([]byte("\"error\":\"" + err.Error() + "\""))
}
err = job.Err()
return response, err
}
示例4: handelJob
func (g GearmanWorker) handelJob(job worker.Job) ([]byte, error) {
secret := job.Data()
if g.aesECBDecrypter != nil {
var err error
secret, err = g.aesECBDecrypter.Decypt(secret)
if err != nil {
g.log.Warn(err, ". Data: ", string(job.Data()))
return job.Data(), nil
}
}
splittedPerformanceData := helper.StringToMap(string(secret), "\t", "::")
g.log.Debug("[ModGearman] ", string(job.Data()))
g.log.Debug("[ModGearman] ", splittedPerformanceData)
for singlePerfdata := range g.nagiosSpoolfileWorker.PerformanceDataIterator(splittedPerformanceData) {
for _, r := range g.results {
select {
case r <- singlePerfdata:
case <-time.After(time.Duration(1) * time.Minute):
logging.GetLogger().Warn("GearmanWorker: Could not write to buffer")
}
}
}
return job.Data(), nil
}
示例5: ToUpperDelay10
func ToUpperDelay10(job worker.Job) ([]byte, error) {
log.Printf("ToUpper: Data=[%s]\n", job.Data())
time.Sleep(10 * time.Second)
data := []byte(strings.ToUpper(string(job.Data())))
return data, nil
}
示例6: ToUpper
func ToUpper(job worker.Job) ([]byte, error) {
log.Printf("ToUpper: Data=[%s]\n", job.Data())
data := []byte(strings.ToUpper(string(job.Data())))
return data, nil
}