thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Terry Jones <>
Subject Re: Python server over HTTP, HTTPS -- How?
Date Fri, 03 Apr 2009 08:47:03 GMT
>>>>> "Brian" == Brian Hammond <> writes:
Brian> I guess there's a few options for python but none completely solve
Brian> both of these requirements.

Brian> 1) use the Twisted python generator and run a daemon with twistd
Brian> 2) deploy to nginx/apache with mod_wsgi and somehow hook-in support  
Brian> for decoding HTTP / HTTPS requests as Thrift RPCs.

Brian> In the first option I would have to run Twisted's webserver with SSL
Brian> support.  This is different from the Twisted code generator solution
Brian> which generates a standalone Twisted-based server.  Thus, I'm not
Brian> sure how to continue with this option.

Hi Brian

If you use the Twisted Python generator it doesn't generate you a
standalone server.

On the server side it generates a class to handle the incoming requests,
provides some protocols and factories in thrift.transport.TTwisted (and, in
the contrib directory of txAMQP, you'll find code for Thrift-based AMQP
clients in case that's useful). It's left for you to decide how to hook
these things up.

So you can build a single Twisted plugin that talks plain TCP/IP or uses
SSL, etc. These interfaces can provide access to the same underlying
handler, or to two different handlers (one doing auth, one doing the more
mundane stuff). You can even use HTTP if you want to :-) You just create
(Thrift and) Twisted services, add them to a standard Twisted MultiService
and use twistd as the daemon process that launches the overall service.
That's all the standard Twisted approach to writing servers using their
plugin architecture (you can do the same with a tac file if you like).

Being also able to make Thrift calls transparently through AMQP is really
nice.  Among other things, it allows you to also add an AMQP client to your
outward-facing Twisted service (using the above-mentioned AMQP client code)
and then have its handler pass requests on to other (internal) services
listening on queues attached to an AMQP broker. The receiving services are
also Twisted AMQP clients, are also receiving method calls via txAMQP /
Thrift, are hooked up in exactly the same manner (as Twisted plugins), and
it all Just Works.

The real expert on this is Esteve Fernandez, who's also on this list. He's
away right now but will be back in action early next week. I'm just a happy
user of txAMQP - exactly as above.


View raw message