Created
February 24, 2019 20:38
-
-
Save riquellopes/5dc4433bf942ed822e967cfc139056f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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