-
Notifications
You must be signed in to change notification settings - Fork 346
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
Explicit autobatching #3216
Labels
fhir-datastore
Related to the FHIR datastore, includes API and FHIR operations
Milestone
Comments
@rahul1 how is this intended to work in the following example? async function doThing() {
medplum.startBatch()
const patients = await Promise.all([
medplum.readResource('Patient', '1'),
medplum.readResource('Patient', '2'),
medplum.readResource('Patient', '3'),
])
medplum.endBatch()
}
doThing()
doThing() Would subsequent Maybe a batch identifier could be provided or the startBatch call could return an identifier? async function doThing(batchIdentifier: string) {
medplum.startBatch(batchIdentifier)
const patients = await Promise.all([
medplum.readResource('Patient', '1', { batchIdentifier }),
medplum.readResource('Patient', '2', { batchIdentifier }),
medplum.readResource('Patient', '3', { batchIdentifier }),
])
medplum.endBatch(batchIdentifier)
}
doThing("1")
doThing("2")
doThing("1") // This could block until the first call to `doThing("1")` finishes its batch. Ideally, unique batch ids would be provided so this shouldn't be encountered but this behavior would need to be documented. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Background
Right now, Medplum supports time-based autobatching. This works great for front-end applications. For backend / server applications, developers have asked for more control over which requests are part of a batch request.
Proposal
add a
startBatch()
andendBatch()
method to theMedplumClient
, to be used as follows:The text was updated successfully, but these errors were encountered: