funcmike / rabbitmq-nio

A Swift implementation of AMQP 0.9.1 protocol: decoder + encoder and non-blocking client
Apache License 2.0
44 stars 8 forks source link

Improve AsyncStream usage #14

Closed funcmike closed 1 year ago

funcmike commented 1 year ago

Currently basicCancel() needs to be called explicitly when iteration has finished - it can be done automatically on consumer deinit.

for await msg in consumer {
    guard case .success(let delivery) = msg else {
        print("Delivery failure", msg)
        return
    }

    print("Succesfully consumed a message", delivery)
    break
}

try await channel.basicCancel(consumerTag: consumer.name) // users should not have to call this. this should be automatic once you leave the iteration