Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to fetch Job Object in Perform function #80

Open
SteveBasik opened this issue May 6, 2024 · 3 comments
Open

Unable to fetch Job Object in Perform function #80

SteveBasik opened this issue May 6, 2024 · 3 comments

Comments

@SteveBasik
Copy link

SteveBasik commented May 6, 2024

I recently integrated Faktory into my GO application. I initialized a worker manager with the job type and the Perform function as mentioned below

mgr.Register("TicketGeneration", ReceiveJobs)

In the "ReceiveJobs" function I only get access to the "args". However, I am not able to fetch the "Job". From the context I'm only able to fetch the "Helper" object.

func ReceiveJobs(ctx context.Context, args ...interface{}) {
      help := worker.HelperFor(ctx)
}
 Jid() string
 JobType() string
 Bid() string
 Batch(func(*client.Batch) error) error
 With(func(*client.Client) error) error
 TrackProgress(percent int, desc string, reserveUntil *time.Time) error

Is there a way that I can use the "Jid" from the helper object to fetch the job object ?

@mperham
Copy link
Contributor

mperham commented May 6, 2024

Nope. The job is an internal structure and not available to the worker. What are you trying to do?

@SteveBasik
Copy link
Author

Nope. The job is an internal structure and not available to the worker. What are you trying to do?

My objective is to send a discord message when my job has 0 retries remaining. In order to do that I thought I would be able to check the retry remaining variable in the job object when it reaches the Perform function. Is there any other way that I can track the number of retries remaining when i receive the args in the perform function so that i can send out an alert to my discord channel to know that the job has exhausted it's retries and has failed ?

@SteveBasik
Copy link
Author

I just need a way to monitor the retry attempts as the job is queued and requeued through code so that i can handle sending of alerts when all retries have been exhausted. Any way to keep track of the retry count would be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants