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

Further defer batch creation #913

Open
bensheldon opened this issue Apr 3, 2023 · 0 comments
Open

Further defer batch creation #913

bensheldon opened this issue Apr 3, 2023 · 0 comments

Comments

@bensheldon
Copy link
Owner

Thinking about #912, and looking at the Batch code, I think that it would be possible to defer creating the batch.

For example, if no jobs are added to a batch, don't save it yet:

def add(active_jobs = nil, &block)

Further, I wonder if add should not actually enqueue the jobs, and instead the batch would store the buffer of unpersisted jobs until enqueue was called. This feels like a breaking change... but I also think it's a necessary one (I'm not sure of the use-case why someone would want to add jobs to a batch but not have them trigger an enqueue callback). This also makes the Batch more idempotent (the whole enqueue step maybe could be done in a transaction, for example)

@bensheldon bensheldon changed the title Further batch creation Further defer batch creation Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Inbox
Development

No branches or pull requests

1 participant