dev:browser_staff:angular_serialize
Serialized Batch Request Example
Parallel batches of network requests have proven to be problematic for Evergreen in cases where the number of requests is high, since this can cause resource exhaustion on the server (e.g. maxing out open-ils.actor drones).
Here's an example of a batch operation that performs a series of operations, while requiring each operation (a network request) to complete before the next request can start.
import {from} from 'rxjs'; import {concatMap} from 'rxjs/operators'; // Marking a list of barcodes as lost, one barcode at a time, with a progress dialog to provide context. // dialog is defined elsewhere. const barcodes = [barcode1, barcode2, ...]; dialog.open(); from(barcodes).pipe(concatMap(barcode => { return this.net.request( 'open-ils.circ', 'open-ils.circ.circulation.set_lost', this.auth.token(), {barcode: barcode} ); })).subscribe( res => dialog.increment(), err => console.error(err), () => dialog.close() );
dev/browser_staff/angular_serialize.txt · Last modified: 2022/02/10 13:34 by 127.0.0.1