-
Notifications
You must be signed in to change notification settings - Fork 334
imapclient: implement Client.Closed #721
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
Conversation
|
I've implemented by particular case in some other way, but this sounds useful to have. I have no strong objections if you'd prefer to close this PR. |
|
I was wondering about the use-case for this. I initially thought I needed something similar for alps, but then figured it wouldn't help much:
|
The channel is not intended to be checked before sending a message, but to re-connect automatically when the connection terminates (i.e.: in the case of NOTIFY). |
|
Previously, the Notify.Overflow channel in #718 would also be closed when the connection dropped (a convenient side-effect). This allowed me to detect when a connection had been closed. Having switched NOTIFY to use a UnilateralDataHandler for NOTIFYOVERFLOW events, I once again need this feature. I don't think I have any other way of detecting when the connection has been closed. I'm only waiting for NOTIFY events, so never send any messages. |
|
Hm, right, that's a good point. I think NOTIFY is special here: with IDLE, clients could call |
| } | ||
| } | ||
|
|
||
| func ExampleClient_Closed() { |
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.
This example is racy (the main function doesn't typically wait for other goroutines to finish) and doesn't reflect real-world usage. Could we drop this example for now, and wait for NOTIFY to be implemented to add a Notify example which leverages Closed to figure out when the connection has been closed?
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.
Example redone.
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.
The example still feels a bit artificial - but let's revisit this with NOTIFY.
4750b35 to
00fde73
Compare
Implement a Client.Closed() to be used by clients to monitor when a connection is closed.
emersion
left a comment
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.
Thanks!
Implement a Client.Closed() to be used by clients to monitor when a connection is closed.