Skip to content

Commit

Permalink
Added Lock and Unlock functions
Browse files Browse the repository at this point in the history
  • Loading branch information
reactorcoremeltdown committed Jan 16, 2024
1 parent 3c755c2 commit 44e72b4
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion pkg/client/fsmq.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,49 @@ func AckJob(url, token, queue, job string) (err error) {

_, err := http.PostForm(url+"queue/ack-job", data)
if err != nil {
log.Println("Failed to fetch job payload: " + err.Error())
log.Println("Failed to ack job: " + err.Error())
}
time.Sleep(200 * time.Millisecond)

return
}

func LockJob(url, token, queue, job string) (err error) {
disposableToken, err := GetDisposableToken(url, token)
if err != nil {
log.Println("Failed to get FSMQ token for LockJob operation: " + err.Error())
return
}
data := url.Values{
"token": {disposableToken},
"queue": {queue},
"job": {job},
}

_, err := http.PostForm(url+"queue/lock-job", data)
if err != nil {
log.Println("Failed to lock job: " + err.Error())
}
time.Sleep(200 * time.Millisecond)

return
}

func UnlockJob(url, token, queue, job string) (err error) {
disposableToken, err := GetDisposableToken(url, token)
if err != nil {
log.Println("Failed to get FSMQ token for LockJob operation: " + err.Error())
return
}
data := url.Values{
"token": {disposableToken},
"queue": {queue},
"job": {job},
}

_, err := http.PostForm(url+"queue/unlock-job", data)
if err != nil {
log.Println("Failed to unlock job: " + err.Error())
}
time.Sleep(200 * time.Millisecond)

Expand Down

0 comments on commit 44e72b4

Please sign in to comment.