Thrift::Parser - A Thrift message (de)serialization OO representation
use Thrift; use Thrift::Parser; use Thrift::IDL; my $parser = Thrift::Parser->new( idl => Thrift::IDL->parse_thrift_file('tutorial.thrift'), service => 'Calculator', ); ## Parse a payload # Obtain a Thrift::Protocol subclass somehow with a loaded buffer my $buffer = ...; my $protocol = Thrift::BinaryProtocol->new($buffer); my $message = $parser->parse_message($protocol); print "Received method call " . $message->method->name . "\n"; ## Use the auto-generated classes to create request/responses my $request = tutorial::Calculator::add->compose_message_call( num1 => 15, num2 => 33, ); my $response = $request->compose_reply(48);
This module provides strict typing and full object orientation of all the Thrift types. It allows you, with a Thrift::IDL object, to create a parser which can parse any Thrift::Protocol object into a message object, and creates dynamic classes according to the IDL specification, allowing you to create method calls, objects, and responses.
my $parser = Thrift::Parser->new( idl => Thrift::IDL->parse_thrift_file('..'), service => 'myServiceName', )
Creates the Parser object and dynamic classes from the IDL file.
my $message = $parser->parse_message($transport);
Given a Thrift::Transport object, the parser will create a Thrift::Parser::Message object.
$parser->full_docs_to_dir($dir, $format);
Using the dynamically generated classes, this will create 'pod' or 'pm' files in the target directory in the following format:
$dir/tutorial::Calculator::testVars.pod (or with format 'pm') $dir/tutorial/Calculator/testVars.pm
The directory will be created if it doesn't exist.
my $fieldset = $parser->parse_structure($transport, $thrift_idl_method->arguments);
Returns a Thrift::Parser::FieldSet. Attempts to read a structure off the transport, using an array of Thrift::IDL::Field objects to define the specification of the structure.
my $typed_value = $parser->parse_type($transport, { idl => $thrift_idl_type_object || type => 4 });
Reads a single value off the transport and returns it as an object in a Thrift::Parser::Type subclass.
my $parser_type_class = $parser->idl_type_class($thrift_idl_type_object);
Maps the given Thrift::IDL::Type object to one in my parser namespace. If it's a custom type, it'll map into a dynamic class.
my $thrift_idl_type_object = $parser->resolve_idl_type($thrift_idl_custom_type_object);
Returns the base Thrift::IDL::Type object from the given Thrift::IDL::Type::Custom object
Thrift, Thrift::IDL
This module is being developed via a git repository publicly available at http://github.com/ewaters/thrift-parser. I encourage anyone who is interested to fork my code and contribute bug fixes or new features, or just have fun and be creative.
Copyright (c) 2009 Eric Waters and XMission LLC (http://www.xmission.com/). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
Eric Waters <ewaters@gmail.com>
To install Thrift::Parser, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Thrift::Parser
CPAN shell
perl -MCPAN -e shell install Thrift::Parser
For more information on module installation, please visit the detailed CPAN module installation guide.