(intentionally posted to dev and not user)

Suppose I have a stateful service and I'd like to clean up some state
when a client disconnects. IIUC, there's no straight forward way to do
this with Thrift. I'd love to hear what others have done in similar
situations.

I'm trying to figure out if there's a way to support this without
modifying Thrift core (this is all with the Thrift Java library):

* my first instinct was to extend TFramedTransport with a custom
factory that allows adding "listeners" that can be fired on a close.
Unfortunately it seems like TFramedTransport.close is either never
called, or not called when a client disconnects. The actual socket
close is wrapped up inside a TNonblockingSocket within the FrameBuffer
managed by TNonblockingServer. So this approach doesn't work.

* Since the client socket is generated by
TNonblockingServerSocket.accept, I next considered overriding
accemptImpl() in a custom ServerSocket. This poses other problems --
because much of the state in TNonblockingServerSocket is private, I
need to use super.acceptImpl() to obtain the TNonblockingSocket (or
reimplement everything). This in turn is not helpful because I then
need to wrap the returned TNonblockingSocket in another "forwarding
object" such that the listeners can be fired when the socket is
closed.

Any thoughts or suggestions welcome!

cheers,
Diwaker

Reply via email to