thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anner van Hardenbroek <dwlne...@users.sourceforge.net>
Subject Introduction of Thrift Console
Date Tue, 23 Feb 2010 03:39:30 GMT
Hi Folks,

First I'd like to thank the Facebook engineers for creating Thrift and the
community for supporting the effort.

I'm currently working on a utility and domain specific language for
scripting a Thrift client. It's conveniently called "Thrift Console" and the
"Thrift Console Scripting Language" or for short "TConsole" and "TCSL". It's
essentially a language specification and a reference implementation with
some nice things like tab completion. I've created the project because I'd
like to have a console-oriented tool to access Thrift services when I'm
developing services. It's designed to be super simple and straight-forward
to interact with services.

My implementation is in Java but TCSL is designed to fit principles that are
not too hard to implement in an other language. The language defines ways
for interaction with collections (set, list and map), loading files (in my
implementation JARs and directories of Java class files) for importing
TTransports, TProtocols and more importantly compiled generated Thrift
source, variables and method invocation. It currently lacks features like
arithmetic <http://en.wikipedia.org/wiki/Arithmetic>, subroutine
declarations <http://en.wikipedia.org/wiki/Subroutine>, explicit
types<http://en.wikipedia.org/wiki/Data_type>,
explicit type conversion
<http://en.wikipedia.org/wiki/Type_conversion> and conditional
statements <http://en.wikipedia.org/wiki/Conditional_(programming)>. However
type conversion is a special story because there *are* types, because we're
talking Java. So, right before method invocations, the arguments are matched
up with the method signature and than converted by the runtime.

I'd like to give an example script to get a feeling:

> // Set transport for communication. We need first a TSocket before we can
> use it as argument.
> set transport TFramedTransport `TSocket localhost 9090`
>
> // Set protocol for communication.
> set protocol TBinaryProtocol
>
> // Import compiled source, generated by Thrift.
> import /path/to/generated/thrift/tutorial
>
> // Set the current service definiton to Calculator service from Thrift
> tutorial.
> set service Calculator
>
> // Open transport.
> // This statement isn't required, because it's implicitly opened by the
> first method invocation.
> transport open
>
> // Invoke add(1:i32 num1, 2:i32 num2) method on server, and print result.
> print client add 1 5
>
> // Invoke calculate(1:i32 logid, 2:Work w) method on server and print
> result.
> print client calculate 324 `Work 13 482 MULTIPLY`
>
> // Invoke calculate(1:i32 logid, 2:Work w) method on server by using enum
> value and comment.
> // Strings can be escaped with both single and double quotes. It's required
> when there are
> // spaces in the string.
> client calculate 324 `Work 748 74 2 "Subtraction of 748 and 74."`
>
> // Close transport. When omitted, it's implicitly called by changing
> transport or exit of runtime.
> transport close
>

> // Stop execution. Initially introduced for use in the console mode, but
> it's also valid and
> // works when executing script files.
> exit
>

As you can see it's fairly straight-forward and understandable. I think it's
a good replacement for creating an utility for doing exact these things most
of the time during development, and keep recompiling or reloading it over
and over. The project can be found at
http://sourceforge.net/projects/tconsole and it's licensed under the BSD
license. I'm committing the code the next week, I think. It is not ready for
production yet and should be used as alpha/beta software.

I've some awesome next-step ideas for the project, like:

   - a 'generate' statement to execute a Thrift file generation
   - a 'compile' statement to compile a bunch of Thrift generated Java
   sources without leaving the console
   - a 'reload' statement to reload loaded files so you don't need to
   restart the console.
   - a service debugger (something like TDebugProtocol, PeekProcessor and
   StatsProcessor)
   - service benchmarking?
   - ...

But first there need other work to be done like documenting and writing the
formal specification. Your help is welcome!

Thanks again for Thrift and the community efforts.

Kind regards,
Anner.

--

Anner van Hardenbroek,
dwlnetnl@users.sourceforge.net

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message