User Tools

Site Tools


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

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki

© 2008-2022 GPLS and others. Evergreen is open source software, freely licensed under GNU GPLv2 or later.
The Evergreen Project is a U.S. 501(c)3 non-profit organization.