當前位置: 首頁>>代碼示例>>Golang>>正文


Golang worker.Job類代碼示例

本文整理匯總了Golang中github.com/mikespook/gearman-go/worker.Job的典型用法代碼示例。如果您正苦於以下問題:Golang Job類的具體用法?Golang Job怎麽用?Golang Job使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Job類的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
}
開發者ID:eeertekin,項目名稱:gearman-go,代碼行數:9,代碼來源:worker.go

示例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
}
開發者ID:zxsted,項目名稱:huabot-brain,代碼行數:15,代碼來源:main.go

示例3: 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
}
開發者ID:Griesbacher,項目名稱:nagflux,代碼行數:24,代碼來源:gearmanWorker.go

示例4: 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
}
開發者ID:CPSSD,項目名稱:feedlark,代碼行數:22,代碼來源:adder.go

示例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
}
開發者ID:jefff,項目名稱:gearman-go,代碼行數:6,代碼來源:worker.go

示例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
}
開發者ID:jefff,項目名稱:gearman-go,代碼行數:5,代碼來源:worker.go


注:本文中的github.com/mikespook/gearman-go/worker.Job類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。