2 use strict; use warnings;
4 my $config = shift || die "Please specify a config file\n";
5 my $context = shift || 'opensrf';
7 my $oils_reqr = 'BINDIR/oils_requestor'; # XXX command line param
9 if(1) { # XXX command line param
11 # ------------------------------------------------------------
12 # This sends the method calls to storage via oils_requestor,
13 # which is able to process the results much faster
14 # Make this the default for now.
15 # ------------------------------------------------------------
17 use OpenSRF::Utils::JSON;
18 use IPC::Open2 qw/open2/;
19 use Net::Domain qw/hostfqdn/;
24 my $hostname = hostfqdn();
25 my $command = "echo \"open-ils.storage $method\" | $oils_reqr -f $config -c $context -h $hostname";
28 my ($child_stdout, $child_stdin);
29 my $pid = open2($child_stdout, $child_stdin, $command);
31 for my $barcode (<$child_stdout>) {
32 next if $barcode =~ /^oils/o; # hack to chop out the oils_requestor prompt
34 $barcode = OpenSRF::Utils::JSON->JSON2perl($barcode);
35 print "$barcode $flag\n" if $barcode;
39 waitpid($pid, 0); # don't leave any zombies (see ipc::open2)
42 runmethod('open-ils.storage.actor.user.lost_barcodes', 'L');
43 runmethod('open-ils.storage.actor.user.barred_barcodes', 'B');
44 runmethod('open-ils.storage.actor.user.penalized_barcodes', 'D');
45 # too many, makes the file too large for download
46 #runmethod('open-ils.storage.actor.user.expired_barcodes', 'E');
51 # ------------------------------------------------------------
52 # Uses the traditional opensrf Perl API approach
53 # ------------------------------------------------------------
55 use OpenSRF::EX qw(:try);
57 use OpenSRF::AppSession;
59 OpenSRF::System->bootstrap_client( config_file => $config );
61 my $ses = OpenSRF::AppSession->connect( 'open-ils.storage' );
63 my $lost = $ses->request( 'open-ils.storage.actor.user.lost_barcodes' );
64 while (my $resp = $lost->recv ) {
65 print $resp->content . " L\n";
69 if(0) { # XXX just too many... arg
70 my $expired = $ses->request( 'open-ils.storage.actor.user.expired_barcodes' );
71 while (my $resp = $expired->recv ) {
72 print $resp->content . " E\n";
77 my $barred = $ses->request( 'open-ils.storage.actor.user.barred_barcodes' );
78 while (my $resp = $barred->recv ) {
79 print $resp->content . " B\n";
83 my $penalized = $ses->request( 'open-ils.storage.actor.user.penalized_barcodes' );
84 while (my $resp = $penalized->recv ) {
85 print $resp->content . " D\n";