[Haskell-cafe] External system connections

Richard Wallace rwallace at thewallacepack.net
Sun Jul 10 21:04:01 CEST 2011


Hello all,

I'm trying to understand how to properly structure a connection to an
external system.  I'm writing an application that processes requests
(it's an IRC bot - ya, I've looked at lambabot but it's a bit beyond
my current understanding and I'm really trying to learn this stuff and
find the best way to do that is to write it myself) and sends requests
to an external system, via SOAP.  The SOAP requests should be sent on
separate threads.  The SOAP server requires an initial request for
authentication be made to obtain a token used on subsequent requests.

There are three ways I can structure this.  One is to do the
authentication with the SOAP server when the application starts up and
just use that token for all subsequent requests.  This will fall over
if the token times out and I'd have to restart the application.
Another way is to do authenticate with the server and get a new token
for each request.  This is obviously really inefficient.

What I'd like to do is something a bit smarter.  When a request to the
SOAP server is to be made, if we have a token then we try and use it.
If it fails, we reauthenticate and get a new token.  When establishing
a new token, other threads trying to send SOAP requests should block
until a new token is available.  There are other conditions that
should be handled - such as an exponential back-off when the SOAP
server can't be reached - but I feel like reestablishing the
authentication token is really the key concern here.  Unfortunately, I
have no idea right now how to write this in Haskell.

Any pointers would be awesome.  Thanks!

Rich



More information about the Haskell-Cafe mailing list