Tom Boland
2015-11-17 16:56:40 UTC
Greetings all.
This may be a very basic question. I'm hoping to implement a postfix
policy check client in twisted. It's a simple protocol. You send
newline separated key value pairs like:
recipient=***@ddr.ess
sender=***@ddr.ess
size=1024
helo_name=mail.server
etc..
you terminate the request with an additional newline. The response
comes back like
action=OK
You can send mutliple requests in the same connection. What I'm
envisaging is a module that can be used to provide a deferred
request/response pairing to my calling application. The module class
will manage the single connection to the postfix policy daemon (I'm
actually going to have persistent connections to a few daemons), and
reconnect when necessary etc. Any requests will return a deferred that
I can add callbacks to. How would you design this with twisted? I can
easily envisage a way of using a clientfactory to instantiate separate
connections for each request/response, but actually being able to simply
send a request and receive the single response for that request is
something I'm struggling to do within a LineReceiver instance (for
instance). Would the twisted.protocols.amp module help given that I
can't change the server-side protocol?
Any advice much appreciated!
Thanks. Tom.
This may be a very basic question. I'm hoping to implement a postfix
policy check client in twisted. It's a simple protocol. You send
newline separated key value pairs like:
recipient=***@ddr.ess
sender=***@ddr.ess
size=1024
helo_name=mail.server
etc..
you terminate the request with an additional newline. The response
comes back like
action=OK
You can send mutliple requests in the same connection. What I'm
envisaging is a module that can be used to provide a deferred
request/response pairing to my calling application. The module class
will manage the single connection to the postfix policy daemon (I'm
actually going to have persistent connections to a few daemons), and
reconnect when necessary etc. Any requests will return a deferred that
I can add callbacks to. How would you design this with twisted? I can
easily envisage a way of using a clientfactory to instantiate separate
connections for each request/response, but actually being able to simply
send a request and receive the single response for that request is
something I'm struggling to do within a LineReceiver instance (for
instance). Would the twisted.protocols.amp module help given that I
can't change the server-side protocol?
Any advice much appreciated!
Thanks. Tom.