rabbitmq / rabbitmq-objc-client

RabbitMQ client for Objective-C and Swift
https://rabbitmq.com
Other
241 stars 84 forks source link

Provide predicates for connection and channel status #101

Open michaelklishin opened 7 years ago

michaelklishin commented 7 years ago

Originally filed as #97. Java, .NET, Ruby (Bunny) all provide such predicates.

camelpunch commented 7 years ago

I dodged this originally because the client has an async API. If all other operations are placed on a client-side queue, when would an application want to know if the client is connected - right now or after everything in the queue has been tried?

It might be a confusing experience for the developer if these concepts aren't expressed in the API. We could have both an async (with a block) and immediate predicate, perhaps?

michaelklishin commented 7 years ago

One reason to check connection and channel state would be when you need to know if it's safe to [re-]publish a group of messages, e.g. to sync local mobile app state with that of the server. Note that it's not used to know when a connection succeeded.

In other clients it's a point-in-time predicate. I think this is what #97 is asking about.

camelpunch commented 7 years ago

In that case it feels to me like you'd still want to use a block, because you'd probably want to avoid trying to re-send the messages if, by the time the local queue had been processed, your connection had dropped again.

Another thing to consider is the high likelihood of being in a connection recovery cycle on mobile. During recovery, none of these conditions are sufficient for knowing that it's safe to re-send:

You'd probably want to know that the entire topology had been redeclared before re-sending. Again, this doesn't seem to be covered in other clients, so maybe it isn't actually needed as much as I'm thinking.

michaelklishin commented 7 years ago

I'm still convinced that having a predicate for channels is a good idea and we will get requests for this again and again.

camelpunch commented 7 years ago

I agree - but we should be careful about how it's implemented, or just how it's named, to avoid false / misleading return values.