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

What context is passed into batchFn? #80

Closed
johnmaguire opened this issue Oct 15, 2021 · 2 comments · Fixed by #81
Closed

What context is passed into batchFn? #80

johnmaguire opened this issue Oct 15, 2021 · 2 comments · Fixed by #81
Assignees

Comments

@johnmaguire
Copy link
Contributor

Load() may be called multiple times before batchFn is called. If Load() is called with various contexts, which one is ultimately passed to batchFn?

@tonyghita tonyghita self-assigned this Oct 16, 2021
@johnmaguire
Copy link
Contributor Author

It looks to me from this code here that it will be the first context object passed to Load() during a given batch window:

dataloader/dataloader.go

Lines 237 to 245 in c87fdce

// start the batch window if it hasn't already started.
if l.curBatcher == nil {
l.curBatcher = l.newBatcher(l.silent, l.tracer)
// start the current batcher batch function
go l.curBatcher.batch(originalContext)
// start a sleeper for the current batcher
l.endSleeper = make(chan bool)
go l.sleeper(l.curBatcher, l.endSleeper)
}

This API is a little confusing - perhaps a note in the README would be helpful to clarify.

@tonyghita
Copy link
Member

Thanks @johnmaguire, that's right. A note on the README (and perhaps a comment on the code) could make this a bit clearer.

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

Successfully merging a pull request may close this issue.

2 participants