-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add storage of Queues and Exchanges to QAmqpClient. #27
Conversation
Just discovered you *CAN* delete them yourself safely, and one of the tests does. So best to not assume they'll get deleted by other parties. QPointer takes care of this problem for us.
Since there will be probably many requests for that one. If we're passed in QString() instead of QString(""), we overwrite that with the latter to ensure the name field is never NULL.
How on earth did I expect that to work? Morning cup of tea hasn't kicked in yet, of course I can't assign a const QString passed by reference. Fix egregious PEBKAC-caused compile error.
On 'destroyed', do a clean up of our exchanges and queues.
Something in the back of my mind had me thinking iterator.value was a field not a function. No idea why. Fixed now.
- DON'T rely on sender() - DON'T expect to be able to cast the QObject to a QAmqpChannel and have name() work. This isn't as efficient as I'd like, but it doesn't crash either.
Maybe my laptop is too quick, but it seems the exchange hangs around a little too long for this test to pass.
Same issue, maybe with the state machine the QAmqpQueue takes a little longer to disappear.
*/ | ||
QAmqpChannel* QAmqpChannelHash::get(const QString& name) const | ||
{ | ||
if (name.isNull()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|| name.isEmpty()
, that translates to "is the QString default constructed (QString()), OR is it an empty string ''"
okay! I think those are all my comments 😈 it seems you're still not passing a test, but it might be invalid at this point? |
@sjlongland ping. I think that one test can be disabled considering your changes here. Then we can at least merge this in (sorry this has been somewhat trying) |
Hi Matt,
No problems there. I've just been flat out lately, in addition to the It was experimenting with QAMQP that told me I had problems in my Python The same concepts should work for QAMQP with QStateMachine. I do intend magnitude faster.Stuart Longland (aka Redhatter, VK4MSL) I haven't lost my mind... |
When we initiate a Close, we get a CloseOk in response and on receipt of the CloseOk, we mark the channel as closed and emit a signal to notify everyone else. Great. Now what happens when the server closes the channel? We emit a CloseOk, then… nothing. We do nothing. This fixes this problem, moving the notification/marking logic to a new function and calling that on both Close (sent from server) and CloseOk.
If the server closes the channel on us, re-open it before removing the exchange.
Okay, that's just fixed up the failing test case. Now to address the code style issues. :-) |
That should have addressed the remaining issues, if I've missed anything, let me know. :-) |
Out of interest, I just had a closer look at e.g. to use an existing example in Fysom (a Python state machine):
— https://github.com/mriehl/fysom There, each event gets its own method on the state machine object, which can then be called to signal events to the state machine. It seems We've got a couple of options:
|
@sjlongland I'm really sorry, I've been incredibly busy and this got away from me (shame on me for pinging you in the first place only to disappear 😄). I agree with your wrt QStateMachine, I've often found it lacking for anything but automation of Qt gui states - however I did come to a similar conclusion that this -might- be possible with QAbstractStates. I think for now perhaps the best way to go about it is to continue to use the private enums (unless you're working on something currently) |
@@ -100,6 101,12 @@ class QAMQP_EXPORT QAmqpClientPrivate : public QAmqpMethodFrameHandler | |||
QAMQP::Error error; | |||
QString errorString; | |||
|
|||
/*! Exchange objects */ | |||
QAmqpChannelHash exchanges; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a reason you have two hashes here? QAmqpChannelHash is already built for abstracting the channels themselves, so you can store them all in a single hash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if a user declares an exchange named foo
, and declares a queue named foo
? I'm not sure if that's against the AMQP specs but if permitted, then we'd have two different objects with the same name.
This handles that possibility in the cleanest way I can think of. I figured it was easier to do this than to try and find out if the other was forbidden. :-)
Add storage of Queues and Exchanges to QAmqpClient.
On 08/06/15 23:22, Matt Broadstone wrote:
This is fine, I've been flat out on the python side of things, we're Right now the codebase I'm working on is officially pure Python with the
The other option might be we port the concepts over from Jake Gordon's The existing QStateMachine could also be used, we'd just have to come Regards,Stuart Longland (aka Redhatter, VK4MSL) I haven't lost my mind... http://codeincomplete.com/posts/2014/3/15/javascript_state_machine_v2_3_0/ |
Rather than handing out "new" exchange and queue objects, we conserve memory and channel usage by keeping a list of existing objects.
If an object is asked for by name, we look for the existing object of that name first before declaring a new one. When a queue is asked for without a name, we wait until it is declared (thus given a name by the broker) before we store it.
For exchanges, all exchanges are stored by name: NULL
QStrings
are converted to an empty string to avoid having duplicate references to the "nameless" exchange.