Azure / go-amqp

AMQP 1.0 client library for Go.
https://github.com/Azure/go-amqp
MIT License
106 stars 57 forks source link

Consider adding Done method to Conn, Sender, and Receiver #99

Open jhendrixMSFT opened 2 years ago

jhendrixMSFT commented 2 years ago

This would allow responding to the event that the link has been detached.

jhendrixMSFT commented 2 weeks ago

Should follow the same pattern as context.Done.

func (c *Conn) Done() <-chan error {...}
Gsantomaggio commented 2 weeks ago

I did some tests, and the Sender close is not called when I close/drop the connection linked to the Connection.

For example:

    conn, err := amqp.Dial( .....)
        session, err := conn.NewSession(......)
        sender, err := session.NewSender(...))
         conn.Close() //<------ Connection closed 

https://github.com/Azure/go-amqp/blob/f631e69097193293dd1b0a2177469eafe89e4a06/link.go#L291-L301

So I wondered how to intercept the Sender Receiver close when it is not called directly.

Thank you

jhendrixMSFT commented 1 week ago

Adding Done() <-chan error has a wrinkle. Once the error, assuming there's one, is read from the channel, subsequent reads from the channel will always return nil. Unclear if this is problematic in practice but needs to be thought through.