1 package OpenILS::App::Math;
2 use base qw/OpenILS::Application/;
3 use OpenILS::Application;
4 use OpenILS::Utils::Logger qw/:level/;
5 use OpenILS::DomainObject::oilsResponse;
6 use OpenILS::EX qw/:try/;
12 our $log = 'OpenILS::Utils::Logger';
16 # my( $class, $method_name, $method_proto ) = @_;
18 # if( $method_name eq "add" ) {
22 # if( $method_name eq "sub" ) {
26 # if( $method_name eq "mult" ) {
30 # if( $method_name eq "div" ) {
40 my $method_name = shift;
43 $log->debug( "Creating a client environment", DEBUG );
44 my $session = OpenILS::AppSession->create(
45 "dbmath", sysname => 'math', secret => '12345' );
47 $log->debug( "Sending request to math server", INTERNAL );
49 my $method = OpenILS::DomainObject::oilsMethod->new( method => $method_name );
51 $method->params( @params );
61 my $vv = $session->connect();
64 throw OpenILS::EX::CRITICAL ("DBMath connect attempt timed out");
68 $req = $session->request( $method );
69 $resp = $req->recv(10);
71 } catch OpenILS::DomainObject::oilsAuthException with {
76 $log->error("response is $resp");
77 if ( defined($resp) and $resp and $resp->class->isa('OpenILS::DomainObject::oilsResult') ){
79 $log->debug( "Math server returned " . $resp->toString(1), INTERNAL );
86 if( $resp ) { $log->debug( "Math received \n".$resp->toString(), ERROR ); }
87 else{ $log->debug( "Math received empty value", ERROR ); }
90 throw OpenILS::EX::ERROR ("Did not receive expected data from MathDB");
96 sub add_1_action { 1 };
101 return send_request( "add", @args );
104 sub sub_1_action { 1 };
108 return send_request( "sub", @args );
111 sub mult_1_action { 1 };
115 return send_request( "mult", @args );
118 sub div_1_action { 1 };
122 return send_request( "div", @args );