Merge lp://staging/~free.ekanayaka/txamqp/closing-logic-cleanup into lp://staging/txamqp

Proposed by Free Ekanayaka
Status: Merged
Merged at revision: 76
Proposed branch: lp://staging/~free.ekanayaka/txamqp/closing-logic-cleanup
Merge into: lp://staging/txamqp
Diff against target: 304 lines (+183/-7)
6 files modified
src/txamqp/client.py (+6/-1)
src/txamqp/protocol.py (+50/-5)
src/txamqp/test/test_broker.py (+9/-0)
src/txamqp/test/test_endpoint.py (+1/-1)
src/txamqp/test/test_protocol.py (+113/-0)
src/txamqp/testing.py (+4/-0)
To merge this branch: bzr merge lp://staging/~free.ekanayaka/txamqp/closing-logic-cleanup
Reviewer Review Type Date Requested Status
Adam Collard (community) Approve
Alberto Donato (community) Approve
txAMQP Team Pending
Review via email: mp+296665@code.staging.launchpad.net

Description of the change

This branch implements the following changes:

- TwistedDelegate.connection_close now sends a 'close-ok' method frame before calling AMQClient.doClose. There's no response for this type of method, but it will be confident that it will be written to the transport before closing it, since AMQClient.doClose eventually calls transport.loseConnection(), which does flush buffers before shutting down the socket.

- AMQClient now has a new "disconnected" instance attribute, which is a TwistedEvent that consumer code can wait on in order to know when the transport has actually shut down. This is useful for integrating txamqp with things like twisted.application.internet.ClientService (that would start to connect again as soon as the connection is lost).

- AMQClient.closed is now properly initialized in the __init__ (it was set dynamically before), so it's always safe to inspect it.

- The AMQClient.sendHB LoopingCall now gets the same clock as AMQClient, instead of the global reactor. This makes unit-testing easier.

- AMQClient.queues (of type TimeoutDeferredQueue) also get same clock as AMQClient.

- The "reason" parameter of AMQClient.close is now optional and defaults to ConnectionDone.

- AMQClient.close has a new "within" parameter, which tells the client to possibly try to perform a clean connection shutdown with the 'close'/'close-ok' frames handshake. If the handshake doesn't succeed in "within" seconds, the transport connection gets terminated without handshake. The default of the new parameter is 0, which means "do close immediately without handshake", so there's should be no behavior change at all for existing code, expect that close() now returns a Deferred, but it seems minor, since the non-handshake code is still all synchronous.

- The old AMQClient.close logic has been moved to AMQClient.doClose, which is basically the same pattern as AMQChannel.close/doClose.

- AMQClient.checkHeartbeat now calls abortConnection rather than loseConnection: since the peer is unresponsive it most probably won't perform the TCP closing handshake anyways.

- Unit tests and integration tests where added for all the behavior above.

Phew, that was quite a bit of narrative, really hope the diff isn't controversial :)

After this branch I have a final small one that allows application code to distinguish between connection close errors and channel close errors (with two new subclasses of Close). Other than that I have no immediate pending work on txamqp, but I'd like to resume:

https://code.launchpad.net/~ei-grad/txamqp/publish-confirms

and have support for confirms.

Thanks!

To post a comment you must log in.
83. By Free Ekanayaka

Merge from travis-integration

Revision history for this message
Free Ekanayaka (free.ekanayaka) wrote :

Hi Esteve, any take on this change? Or you didn't have time to look at it yet? Cheers

Revision history for this message
Alberto Donato (ack) wrote :

LGTM. +1

review: Approve
84. By Free Ekanayaka

Fix typo

Revision history for this message
Free Ekanayaka (free.ekanayaka) :
85. By Free Ekanayaka

Merge from trunk

Revision history for this message
Adam Collard (adam-collard) wrote :

We'll need to broadcast the change to the interface as well.

Broadly looks ok - few nit picks inline below.

review: Approve
Revision history for this message
Free Ekanayaka (free.ekanayaka) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches

to status/vote changes: