LP#1754164: fix gateway timeout when retrieving many shelving locations user/jeffdavis/lp1754164-copy-location-gateway-timeout
authorJeff Davis <jdavis@sitka.bclibraries.ca>
Thu, 15 Mar 2018 17:37:31 +0000 (10:37 -0700)
committerJeff Davis <jdavis@sitka.bclibraries.ca>
Thu, 15 Mar 2018 17:42:06 +0000 (10:42 -0700)
A call to open-ils.circ.copy_location.retrieve.all via the gateway can
fail with a large number of shelving locations.  The API call succeeds,
but the gateway reports a timeout and returns null.  Streaming the
response seems to fix the problem.  Thanks to Dan Wells for providing an
example to copy in LP#1756142.

Signed-off-by: Jeff Davis <jdavis@sitka.bclibraries.ca>
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/CopyLocations.pm

index 23061ca..58f5bbf 100644 (file)
@@ -14,6 +14,7 @@ my $U = "OpenILS::Application::AppUtils";
 __PACKAGE__->register_method(
     api_name        => "open-ils.circ.copy_location.retrieve.all",
     method      => 'cl_retrieve_all',
+    stream      => 1,
     argc            =>  2,
     signature   => q/
         Retrieves the ranged set of copy locations for the requested org.
@@ -39,10 +40,12 @@ sub cl_retrieve_all {
         $second_cstore_arg->{"flesh_fields"} = {"acpl" => ["owning_lib"]};
     }
 
-    return new_editor()->search_asset_copy_location([{
+    my $locations = new_editor()->search_asset_copy_location([{
         owning_lib => $U->get_org_full_path($org_id),
        deleted => "f"
     }, $second_cstore_arg]);
+    $client->respond($_) for @$locations;
+    return undef;
 }
 
 __PACKAGE__->register_method(