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

Enque new jobs from within a job #128

Closed
bjartek opened this issue Nov 14, 2022 · 2 comments
Closed

Enque new jobs from within a job #128

bjartek opened this issue Nov 14, 2022 · 2 comments

Comments

@bjartek
Copy link

bjartek commented Nov 14, 2022

A pattern I find myself doing is to have one job that is done at a given interval that creates lots of other jobs. Right now I am doing this via the gueClient but was wonder if there is a way to do this from a job so that it can run in the same transaction.

@vgarvardt
Copy link
Owner

It is possible, but you still need a client, it should look like this:

tx := j.Tx()
err := gueClient.EnqueueTx(ctx, &gue.Job{...}, tx)

so basically j.Tx() returns transaction used for the current job locking

@bjartek
Copy link
Author

bjartek commented Nov 14, 2022

awesome!

@bjartek bjartek closed this as completed Nov 14, 2022
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