====================================================== Call a user program from various programming languages ====================================================== Once a user program run on RaSC following the steps in :doc:`rasc_core`, the user program can be easily called from various programming languages through `MessagePack RPC `_. The following shows examples of calling a user program running on RaSC. The example assumes that ``SERVICE_HOST`` and ``SERVICE_PORT`` are the host and the port of the RaSC service. Call from Perl ============== This example requires `AnyEvent::MPRPC `_. .. code-block:: perl #!/bin/env perl use strict; use warnings; use utf8; use AnyEvent::MPRPC; use AnyEvent::MPRPC::Client; my $client = AnyEvent::MPRPC::Client->new( host => "SERVICE_HOST", port => "SERVICE_PORT" ); my $res = $client->call( 'analyze' => 'String to be analyzed' )->recv; print "$res\n"; my $reqArray = [ "First sentence", "Second sentence" ]; my $resArray = $client->call( 'analyzeArray' => [ $reqArray ] )->recv; print join("\n", @$resArray); Call from Python ================ This example requires `msgpackrpc `_. .. code-block:: python # coding:utf-8 import msgpackrpc client = msgpackrpc.Client(msgpackrpc.Address( "SERVICE_HOST", SERVICE_PORT)) result = client.call('analyze', "String to be analyzed") print(result) resultArray = client.call('analyzeArray', [ "First sentence", "Second sentence" ]) print("\n".join(resultArray)) Call from Ruby ============== This example requires `msgpack-rpc `_. .. code-block:: ruby # -*- coding: utf-8 -*- require 'msgpack/rpc' client = MessagePack::RPC::Client.new('SERVICE_HOST', SERVICE_PORT) result = client.call(:analyze, "String to be analyzed") print(result) resultArray = client.call(:analyzeArray, [ "First sentence", "Second sentence" ]) print(resultArray.join("\n"))