]> git.evergreen-ils.org Git - Evergreen.git/blob - OpenSRF/src/perlmods/OpenSRF/Application.pm
debuging changes
[Evergreen.git] / OpenSRF / src / perlmods / OpenSRF / Application.pm
1 package OpenSRF::Application;
2 use vars qw/$_app $log @_METHODS $thunk $server_class/;
3
4 use base qw/OpenSRF/;
5 use OpenSRF::AppSession;
6 use OpenSRF::DomainObject::oilsMethod;
7 use OpenSRF::DomainObject::oilsResponse qw/:status/;
8 use OpenSRF::Utils::Logger qw/:level/;
9 use Data::Dumper;
10 use Time::HiRes qw/time/;
11 use OpenSRF::EX qw/:try/;
12 use Carp;
13 #use OpenSRF::UnixServer;  # to get the server class from UnixServer::App
14
15 sub DESTROY{};
16
17 use strict;
18 use warnings;
19
20 $log = 'OpenSRF::Utils::Logger';
21
22 our $in_request = 0;
23 our @pending_requests;
24
25 sub package {
26         my $self = shift;
27         return 1 unless ref($self);
28         return $self->{package};
29 }
30
31 sub signature {
32         my $self = shift;
33         return 0 unless ref($self);
34         return $self->{signature};
35 }
36
37 sub argc {
38         my $self = shift;
39         return 0 unless ref($self);
40         return $self->{argc};
41 }
42
43 sub api_name {
44         my $self = shift;
45         return 1 unless ref($self);
46         return $self->{api_name};
47 }
48
49 sub api_level {
50         my $self = shift;
51         return 1 unless ref($self);
52         return $self->{api_level};
53 }
54
55 sub server_class {
56         my $class = shift;
57         if($class) {
58                 $server_class = $class;
59         }
60         return $server_class;
61 }
62
63 sub thunk {
64         my $self = shift;
65         my $flag = shift;
66         $thunk = $flag if (defined $flag);
67         return $thunk;
68 }
69
70 sub application_implementation {
71         my $self = shift;
72         my $app = shift;
73
74         if (defined $app) {
75                 $_app = $app;
76                 $_app->use;
77                 if( $@ ) {
78                         $log->error( "Error loading application_implementation: $app -> $@", ERROR);
79                 }
80
81         }
82
83         return $_app;
84 }
85
86 sub handler {
87         my ($self, $session, $app_msg) = @_;
88
89         if( ! $app_msg ) {
90                 return 1;  # error?
91         }
92
93         $log->debug( "In Application::handler()", DEBUG );
94
95         my $app = $self->application_implementation;
96
97         if( $app ) {
98                 $log->debug( "Application is $app", DEBUG);
99         }
100
101         if ($session->last_message_type eq 'REQUEST') {
102                 $log->debug( "We got a REQUEST: ". $app_msg->method);
103
104                 my $method_name = $app_msg->method;
105                 $log->debug( " * Looking up $method_name inside $app", DEBUG);
106
107                 my $method_proto = $session->last_message_api_level;
108                 $log->debug( " * Method API Level [$method_proto]", DEBUG);
109
110                 my $coderef = $app->method_lookup( $method_name, $method_proto, 1, 1 );
111
112                 unless ($coderef) {
113                         $session->status( OpenSRF::DomainObject::oilsMethodException->new( 
114                                                 statusCode => STATUS_NOTFOUND(),
115                                                 status => "Method [$method_name] not found for $app"));
116                         return 1;
117                 }
118
119                 $log->debug( " (we got coderef $coderef", DEBUG);
120
121                 unless ($session->continue_request) {
122                         $session->status(
123                                 OpenSRF::DomainObject::oilsConnectStatus->new(
124                                                 statusCode => STATUS_REDIRECTED(),
125                                                 status => 'Disconnect on max requests' ) );
126                         $session->kill_me;
127                         return 1;
128                 }
129
130                 if (ref $coderef) {
131                         my @args = $app_msg->params;
132                         my $appreq = OpenSRF::AppRequest->new( $session );
133
134                         $log->debug( "in_request = $in_request : [" . $appreq->threadTrace."]", DEBUG );
135                         if( $in_request ) {
136                                 $log->debug( "Pushing onto pending requests: " . $appreq->threadTrace, DEBUG );
137                                 push @pending_requests, [ $appreq, \@args, $coderef ]; 
138                                 return 1;
139                         }
140
141
142                         $in_request++;
143
144                         $log->debug( "Executing coderef for {$method_name}", INTERNAL );
145
146                         my $resp;
147                         try {
148                                 # un-if(0) this block to enable param checking based on signature and argc
149                                 if (0) {
150                                         if (@args < $coderef->argc) {
151                                                 die     "Not enough params passed to ".
152                                                         $coderef->api_name." : requires ". $coderef->argc
153                                         }
154                                         if (@args) {
155                                                 my $sig = $coderef->signature;
156                                                 if ($sig && exists $sig->{params}) {
157                                                         for my $p (0 .. scalar(@{ $sig->{params} }) - 1 ) {
158                                                                 my $s = $sig->{params}->[$p];
159                                                                 my $a = $args[$p];
160                                                                 if ($s->{class} && JSON->lookup_hint(ref $a) ne $s->{class}) {
161                                                                         die "Incorrect param class at position $p : should be a '$$s{class}'";
162                                                                 } elsif ($s->{type}) {
163                                                                         if (lc($s->{type}) eq 'object' && $a !~ /HASH/o) {
164                                                                                 die "Incorrect param type at position $p : should be an 'object'";
165                                                                         } elsif (lc($s->{type}) eq 'array' && $a !~ /ARRAY/o) {
166                                                                                 die "Incorrect param type at position $p : should be an 'array'";
167                                                                         } elsif (lc($s->{type}) eq 'number' && (ref($a) || $a !~ /^-?\d+(?:\.\d+)?$/o)) {
168                                                                                 die "Incorrect param type at position $p : should be a 'number'";
169                                                                         } elsif (lc($s->{type}) eq 'string' && ref($a)) {
170                                                                                 die "Incorrect param type at position $p : should be a 'string'";
171                                                                         }
172                                                                 }
173                                                         }
174                                                 }
175                                         }
176                                 }
177
178                                 my $start = time();
179                                 warn "About to run...\n";
180                                 $resp = $coderef->run( $appreq, @args); 
181                                 warn "Done running...\n";
182                                 my $time = sprintf '%.3f', time() - $start;
183
184                                 $log->debug( "Method duration for [$method_name]:  ". $time );
185                                 if( defined( $resp ) ) {
186                                         $appreq->respond_complete( $resp );
187                                 } else {
188                                         $appreq->status( OpenSRF::DomainObject::oilsConnectStatus->new(
189                                                                 statusCode => STATUS_COMPLETE(),
190                                                                 status => 'Request Complete' ) );
191                                 }
192                         } catch Error with {
193                                 my $e = shift;
194                                 warn "Caught error from 'run' method: $e\n";
195
196                                 if(UNIVERSAL::isa($e,"Error")) {
197                                         $e = $e->stringify();
198                                 } 
199                                 my $sess_id = $session->session_id;
200                                 $session->status(
201                                         OpenSRF::DomainObject::oilsMethodException->new(
202                                                         statusCode      => STATUS_INTERNALSERVERERROR(),
203                                                         status          => " *** Call to [$method_name] failed for session ".
204                                                                            "[$sess_id], thread trace ".
205                                                                            "[".$appreq->threadTrace."]:\n$e\n"
206                                         )
207                                 );
208                         };
209
210
211
212                         # ----------------------------------------------
213
214
215                         # XXX may need this later
216                         # $_->[1] = 1 for (@OpenSRF::AppSession::_CLIENT_CACHE);
217
218                         $in_request--;
219
220                         $log->debug( "Pending Requests: " . scalar(@pending_requests), INTERNAL );
221
222                         # cycle through queued requests
223                         while( my $aref = shift @pending_requests ) {
224                                 $in_request++;
225                                 my $resp;
226                                 try {
227                                         # un-if(0) this block to enable param checking based on signature and argc
228                                         if (0) {
229                                                 if (@args < $aref->[2]->argc) {
230                                                         die     "Not enough params passed to ".
231                                                                 $aref->[2]->api_name." : requires ". $aref->[2]->argc
232                                                 }
233                                                 if (@args) {
234                                                         my $sig = $aref->[2]->signature;
235                                                         if ($sig && exists $sig->{params}) {
236                                                                 for my $p (0 .. scalar(@{ $sig->{params} }) - 1 ) {
237                                                                         my $s = $sig->{params}->[$p];
238                                                                         my $a = $args[$p];
239                                                                         if ($s->{class} && JSON->lookup_hint(ref $a) ne $s->{class}) {
240                                                                                 die "Incorrect param class at position $p : should be a '$$s{class}'";
241                                                                         } elsif ($s->{type}) {
242                                                                                 if (lc($s->{type}) eq 'object' && $a !~ /HASH/o) {
243                                                                                         die "Incorrect param type at position $p : should be an 'object'";
244                                                                                 } elsif (lc($s->{type}) eq 'array' && $a !~ /ARRAY/o) {
245                                                                                         die "Incorrect param type at position $p : should be an 'array'";
246                                                                                 } elsif (lc($s->{type}) eq 'number' && (ref($a) || $a !~ /^-?\d+(?:\.\d+)?$/o)) {
247                                                                                         die "Incorrect param type at position $p : should be a 'number'";
248                                                                                 } elsif (lc($s->{type}) eq 'string' && ref($a)) {
249                                                                                         die "Incorrect param type at position $p : should be a 'string'";
250                                                                                 }
251                                                                         }
252                                                                 }
253                                                         }
254                                                 }
255                                         }
256
257                                         my $start = time;
258                                         my $response = $aref->[2]->run( $aref->[0], @{$aref->[1]} );
259                                         my $time = sprintf '%.3f', time - $start;
260                                         $log->debug( "Method duration for [".$aref->[2]->api_name." -> ".join(', ',@{$aref->[1]}).']:  '.$time, DEBUG );
261
262                                         $appreq = $aref->[0];   
263                                         if( ref( $response ) ) {
264                                                 $appreq->respond_complete( $response );
265                                         } else {
266                                                 $appreq->status( OpenSRF::DomainObject::oilsConnectStatus->new(
267                                                                         statusCode => STATUS_COMPLETE(),
268                                                                         status => 'Request Complete' ) );
269                                         }
270                                         $log->debug( "Executed: " . $appreq->threadTrace, DEBUG );
271                                 } catch Error with {
272                                         my $e = shift;
273                                         if(UNIVERSAL::isa($e,"Error")) {
274                                                 $e = $e->stringify();
275                                         }
276                                         $session->status(
277                                                 OpenSRF::DomainObject::oilsMethodException->new(
278                                                                 statusCode => STATUS_INTERNALSERVERERROR(),
279                                                                 status => "Call to [".$aref->[2]->api_name."] faild:  $e"
280                                                 )
281                                         );
282                                 };
283                                 $in_request--;
284                         }
285
286                         return 1;
287                 } 
288
289                 $log->info("Received non-REQUEST message in Application handler");
290
291                 my $res = OpenSRF::DomainObject::oilsMethodException->new( 
292                                 status => "Received non-REQUEST message in Application handler");
293                 $session->send('ERROR', $res);
294                 $session->kill_me;
295                 return 1;
296
297         } else {
298                 $session->push_queue([ $app_msg, $session->last_threadTrace ]);
299         }
300
301         $session->last_message_type('');
302         $session->last_message_api_level('');
303
304         return 1;
305 }
306
307 sub is_registered {
308         my $self = shift;
309         my $api_name = shift;
310         my $api_level = shift || 1;
311         return exists($_METHODS[$api_level]{$api_name});
312 }
313
314
315 sub normalize_whitespace {
316         my $txt = shift;
317
318         $txt =~ s/^\s+//gso;
319         $txt =~ s/\s+$//gso;
320         $txt =~ s/\s+/ /gso;
321         $txt =~ s/\n//gso;
322         $txt =~ s/\. /\.  /gso;
323
324         return $txt;
325 }
326
327 sub parse_string_signature {
328         my $string = shift;
329         return [] unless $string;
330         my @chunks = split(/\@/so, $string);
331
332         my @params;
333         my $ret;
334         my $desc = '';
335         for (@chunks) {
336                 if (/^return (.+)$/so) {
337                         $ret = [normalize_whitespace($1)];
338                 } elsif (/^param (\w+) \b(.+)$/so) {
339                         push @params, [ $1, normalize_whitespace($2) ];
340                 } else {
341                         $desc .= '@' if $desc;
342                         $desc .= $_;
343                 }
344         }
345
346         return [normalize_whitespace($desc),\@params, $ret];
347 }
348
349 sub parse_array_signature {
350         my $array = shift;
351         my ($d,$p,$r) = @$array;
352         return {} unless ($d or $p or $r);
353
354         return {
355                 desc    => $d,
356                 params  => [
357                         map { 
358                                 { name  => $$_[0],
359                                   desc  => $$_[1],
360                                   type  => $$_[2],
361                                   class => $$_[3],
362                                 }
363                         } @$p
364                 ],
365                 'return'=>
366                         { desc  => $$r[0],
367                           type  => $$r[1],
368                           class => $$r[2],
369                         }
370         };
371 }
372
373 sub register_method {
374         my $self = shift;
375         my $app = ref($self) || $self;
376         my %args = @_;
377
378
379         throw OpenSRF::DomainObject::oilsMethodException unless ($args{method});
380
381         $args{api_level} = 1 unless(defined($args{api_level}));
382         $args{stream} ||= 0;
383         $args{remote} ||= 0;
384         $args{argc} ||= 0;
385         $args{package} ||= $app;                
386         $args{server_class} = server_class();
387         $args{api_name} ||= $args{server_class} . '.' . $args{method};
388
389         # un-if(0) this block to enable signature parsing
390         if (!$args{signature}) {
391                 if ($args{notes} && !ref($args{notes})) {
392                         $args{signature} =
393                                 parse_array_signature( parse_string_signature( $args{notes} ) );
394                 }
395         } elsif( !ref($args{signature}) ) {
396                 $args{signature} =
397                         parse_array_signature( parse_string_signature( $args{signature} ) );
398         } elsif( ref($args{signature}) eq 'ARRAY') {
399                 $args{signature} =
400                         parse_array_signature( $args{signature} );
401         }
402         
403         unless ($args{object_hint}) {
404                 ($args{object_hint} = $args{package}) =~ s/::/_/go;
405         }
406
407         JSON->register_class_hint( name => $args{package}, hint => $args{object_hint}, type => "hash" );
408
409         $_METHODS[$args{api_level}]{$args{api_name}} = bless \%args => $app;
410
411         __PACKAGE__->register_method(
412                 stream => 0,
413                 argc => $args{argc},
414                 api_name => $args{api_name}.'.atomic',
415                 method => 'make_stream_atomic',
416                 notes => "This is a system generated method.  Please see the definition for $args{api_name}",
417         ) if ($args{stream});
418 }
419
420 sub retrieve_remote_apis {
421         my $method = shift;
422         my $session = OpenSRF::AppSession->create('router');
423         try {
424                 $session->connect or OpenSRF::EX::WARN->throw("Connection to router timed out");
425         } catch Error with {
426                 my $e = shift;
427                 $log->debug( "Remote subrequest returned an error:\n". $e );
428                 return undef;
429         } finally {
430                 return undef unless ($session->state == $session->CONNECTED);
431         };
432
433         my $req = $session->request( 'opensrf.router.info.class.list' );
434         my $list = $req->recv;
435
436         if( UNIVERSAL::isa($list,"Error") ) {
437                 throw $list;
438         }
439
440         my $content = $list->content;
441
442         $req->finish;
443         $session->finish;
444         $session->disconnect;
445
446         my %u_list = map { ($_ => 1) } @$content;
447
448         for my $class ( keys %u_list ) {
449                 next if($class eq $server_class);
450                 populate_remote_method_cache($class, $method);
451         }
452 }
453
454 sub populate_remote_method_cache {
455         my $class = shift;
456         my $meth = shift;
457
458         my $session = OpenSRF::AppSession->create($class);
459         try {
460                 $session->connect or OpenSRF::EX::WARN->throw("Connection to $class timed out");
461
462                 my $call = 'opensrf.system.method.all' unless (defined $meth);
463                 $call = 'opensrf.system.method' if (defined $meth);
464
465                 my $req = $session->request( $call, $meth );
466
467                 while (my $method = $req->recv) {
468                         next if (UNIVERSAL::isa($method, 'Error'));
469
470                         $method = $method->content;
471                         next if ( exists($_METHODS[$$method{api_level}]) &&
472                                 exists($_METHODS[$$method{api_level}]{$$method{api_name}}) );
473                         $method->{remote} = 1;
474                         bless($method, __PACKAGE__ );
475                         $_METHODS[$$method{api_level}]{$$method{api_name}} = $method;
476                 }
477
478                 $req->finish;
479                 $session->finish;
480                 $session->disconnect;
481
482         } catch Error with {
483                 my $e = shift;
484                 $log->debug( "Remote subrequest returned an error:\n". $e );
485                 return undef;
486         };
487 }
488
489 sub method_lookup {             
490         my $self = shift;
491         my $method = shift;
492         my $proto = shift;
493         my $no_recurse = shift || 0;
494         my $no_remote = shift || 0;
495
496         # this instead of " || 1;" above to allow api_level 0
497         $proto = $self->api_level unless (defined $proto);
498
499         my $class = ref($self) || $self;
500
501         $log->debug("Lookup of [$method] by [$class] in api_level [$proto]", DEBUG);
502         $log->debug("Available methods\n\t".join("\n\t", keys %{ $_METHODS[$proto] }), INTERNAL);
503
504         my $meth;
505         if (__PACKAGE__->thunk) {
506                 for my $p ( reverse(1 .. $proto) ) {
507                         if (exists $_METHODS[$p]{$method}) {
508                                 $meth = $_METHODS[$p]{$method};
509                         }
510                 }
511         } else {
512                 if (exists $_METHODS[$proto]{$method}) {
513                         $meth = $_METHODS[$proto]{$method};
514                 }
515         }
516
517         if (defined $meth) {
518                 $log->debug("Looks like we found [$method]!", DEBUG);
519                 $log->debug("Method object is ".Dumper($meth), INTERNAL);
520                 if($no_remote and $meth->{remote}) {
521                         $log->debug("OH CRAP We're not supposed to return remote methods", WARN);
522                         return undef;
523                 }
524
525         } elsif (!$no_recurse) {
526                 $log->debug("We didn't find [$method], asking everyone else.", DEBUG);
527                 retrieve_remote_apis($method);
528                 $meth = $self->method_lookup($method,$proto,1);
529         }
530
531         return $meth;
532 }
533
534 sub run {
535         my $self = shift;
536         my $req = shift;
537
538         my $resp;
539         my @params = @_;
540
541         if ( !UNIVERSAL::isa($req, 'OpenSRF::AppRequest') ) {
542                 $log->debug("Creating a SubRequest object", DEBUG);
543                 unshift @params, $req;
544                 $req = OpenSRF::AppSubrequest->new;
545         } else {
546                 $log->debug("This is a top level request", DEBUG);
547         }
548
549         if (!$self->{remote}) {
550                 my $code ||= \&{$self->{package} . '::' . $self->{method}};
551                 $log->debug("Created coderef [$code] for $$self{package}::$$self{method}",DEBUG);
552                 my $err = undef;
553
554                 try {
555                         $resp = $code->($self, $req, @params);
556
557                 } catch Error with {
558                         my $e = shift;
559                         $err = $e;
560                         warn "Method 'run' catching error: $e\n";
561
562                         if( ref($self) eq 'HASH') {
563                                 $log->error("Sub $$self{package}::$$self{method} DIED!!!\n\t$e\n", ERROR);
564                         }
565                 };
566
567                 if($err) {
568                         if(UNIVERSAL::isa($err,"Error")) { 
569                                 warn "Throwing from method run:\n$err\n------------------\n";
570                                 throw $err;
571                         } else {
572                                 die $err->stringify; 
573                         }
574                 }
575
576
577                 $log->debug("Coderef for [$$self{package}::$$self{method}] has been run", DEBUG);
578
579                 if ( ref($req) and UNIVERSAL::isa($req, 'OpenSRF::AppSubrequest') ) {
580                         $log->debug("A SubRequest object is responding", DEBUG);
581                         $req->respond($resp) if (defined $resp);
582                         $log->debug("... Responding with : " . join(" ",$req->responses), DEBUG);
583                         return $req->responses;
584                 } else {
585                         $log->debug("A top level Request object is responding $resp", DEBUG) if (defined $resp);
586                         return $resp;
587                 }
588         } else {
589                 my $session = OpenSRF::AppSession->create($self->{server_class});
590                 try {
591                         #$session->connect or OpenSRF::EX::WARN->throw("Connection to [$$self{server_class}] timed out");
592                         my $remote_req = $session->request( $self->{api_name}, @params );
593                         while (my $remote_resp = $remote_req->recv) {
594                                 OpenSRF::Utils::Logger->debug("Remote Subrequest Received " . $remote_resp, INTERNAL );
595                                 if( UNIVERSAL::isa($remote_resp,"Error") ) {
596                                         throw $remote_resp;
597                                 }
598                                 $req->respond( $remote_resp->content );
599                         }
600                         $remote_req->finish();
601
602                 } catch Error with {
603                         my $e = shift;
604                         $log->debug( "Remote subrequest returned an error:\n". $e );
605                         return undef;
606                 };
607
608                 if ($session) {
609                         $session->disconnect();
610                         $session->finish();
611                 }
612
613                 $log->debug( "Remote Subrequest Responses " . join(" ", $req->responses), INTERNAL );
614
615                 return $req->responses;
616         }
617         # huh? how'd we get here...
618         return undef;
619 }
620
621 sub introspect {
622         my $self = shift;
623         my $client = shift;
624         my $method = shift;
625         my $limit = shift;
626         my $offset = shift;
627
628         if ($self->api_name =~ /all$/o) {
629                 $offset = $limit;
630                 $limit = $method;
631                 $method = undef; 
632         }
633
634         my ($seen,$returned) = (0,0);
635         for my $api_level ( reverse(1 .. $#_METHODS) ) {
636                 for my $api_name ( sort keys %{$_METHODS[$api_level]} ) {
637                         if (!$offset || $offset <= $seen) {
638                                 if (!$_METHODS[$api_level]{$api_name}{remote}) {
639                                         if (defined($method)) {
640                                                 if ($api_name =~ $method) {
641                                                         if (!$limit || $returned < $limit) {
642                                                                 $client->respond( $_METHODS[$api_level]{$api_name} );
643                                                                 $returned++;
644                                                         }
645                                                 }
646                                         } else {
647                                                 if (!$limit || $returned < $limit) {
648                                                         $client->respond( $_METHODS[$api_level]{$api_name} );
649                                                         $returned++;
650                                                 }
651                                         }
652                                 }
653                         }
654                         $seen++;
655                 }
656         }
657
658         return undef;
659 }
660 __PACKAGE__->register_method(
661         stream => 1,
662         method => 'introspect',
663         api_name => 'opensrf.system.method.all',
664         argc => 0,
665         signature => {
666                 desc => q/This method is used to introspect an entire OpenSRF Application/,
667                 return => {
668                         desc => q/A stream of objects describing the methods available via this OpenSRF Application/,
669                         type => 'object'
670                 }
671         },
672 );
673 __PACKAGE__->register_method(
674         stream => 1,
675         method => 'introspect',
676         argc => 1,
677         api_name => 'opensrf.system.method',
678         argc => 1,
679         signature => {
680                 desc => q/Use this method to get the definition of a single OpenSRF Method/,
681                 params => [
682                         { desc => q/The method to introspect/,
683                           type => 'string' },
684                 ],
685                 return => { desc => q/An object describing the method requested, or an error if it can't be found/,
686                             type => 'object' }
687         },
688 );
689
690 sub echo_method {
691         my $self = shift;
692         my $client = shift;
693         my @args = @_;
694
695         $client->respond( $_ ) for (@args);
696         return undef;
697 }
698 __PACKAGE__->register_method(
699         stream => 1,
700         method => 'echo_method',
701         argc => 1,
702         api_name => 'opensrf.system.echo',
703         signature => {
704                 desc => q/A test method that will echo back it's arguments in a streaming response/,
705                 params => [
706                         { desc => q/One or more arguments to echo back/ }
707                 ],
708                 return => { desc => q/A stream of the arguments passed/ }
709         },
710 );
711
712 sub time_method {
713         my( $self, $conn ) = @_;
714         return CORE::time;
715 }
716 __PACKAGE__->register_method(
717         method => 'time_method',
718         argc => 0,
719         api_name => 'opensrf.system.time',
720         signature => {
721                 desc => q/Returns the current system time as epoch seconds/,
722                 return => { desc => q/epoch seconds/ }
723         }
724 );
725
726 sub make_stream_atomic {
727         my $self = shift;
728         my $req = shift;
729         my @args = @_;
730
731         (my $m_name = $self->api_name) =~ s/\.atomic$//o;
732         my @results = $self->method_lookup($m_name)->run(@args);
733
734         return \@results;
735 }
736
737
738 1;
739
740