Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Thrift Wiki" for change 
notification.

The following page has been changed by JonSchutz:
http://wiki.apache.org/thrift/ThriftUsagePerl

New page:
An example using Thrift and Scribe (see 
[http://notes.jschutz.net/109/perl/perl-client-for-facebooks-scribe-logging-software
 here for more details about building the perl scribe client]).

The example program reads one line at a time from stdin and sends to a scribe 
instance running locally on port 1465.

{{{
      #! /usr/bin/perl

      use Scribe::Thrift::scribe;
      use Thrift::Socket;
      use Thrift::FramedTransport;
      use Thrift::BinaryProtocol;
      use strict;
      use warnings;

      my $host = 'localhost';
      my $port = 1465;
      my $cat = $ARGV[0] || 'test';

      my $socket = Thrift::Socket->new($host, $port);
      my $transport = Thrift::FramedTransport->new($socket);
      my $proto = Thrift::BinaryProtocol->new($transport);

      my $client = Scribe::Thrift::scribeClient->new($proto, $proto);
      my $le = Scribe::Thrift::LogEntry->new({ category => $cat });

      $transport->open();

      while (my $line = <>) {
          $le->message($line);
          my $result = $client->Log([ $le ]);
          if ($result == Scribe::Thrift::ResultCode::TRY_LATER) {
              print STDERR "TRY_LATER\n";
          }
          elsif ($result != Scribe::Thrift::ResultCode::OK) {
              print STDERR "Unknown result code: $result\n";
          }
      }

      $transport->close();
}}}

Reply via email to