Skip to content

Instantly share code, notes, and snippets.

@riquellopes
Created February 24, 2019 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save riquellopes/5dc4433bf942ed822e967cfc139056f0 to your computer and use it in GitHub Desktop.
Save riquellopes/5dc4433bf942ed822e967cfc139056f0 to your computer and use it in GitHub Desktop.
package tasks
import (
"log"
"math/rand"
"github.com/zeebe-io/zeebe/clients/go/entities"
"github.com/zeebe-io/zeebe/clients/go/worker"
)
//CheckAvailability -
func CheckAvailability(client worker.JobClient, job entities.Job) {
jobKey := job.GetKey()
payload, err := job.GetPayloadAsMap()
if err != nil {
// failed to handle job as we require the payload
failJob(client, job)
return
}
payload["available"] = rand.Int()%2 == 0
request, err := client.NewCompleteJobCommand().JobKey(jobKey).PayloadFromMap(payload)
if err != nil {
// failed to set the updated payload
failJob(client, job)
return
}
log.Println("Complete job", jobKey, "of type", job.Type)
request.Send()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment