diff --git a/README.md b/README.md index bb1060b3..ca5f4b18 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,7 @@ may lead to messages being silently dropped. * `persistence` - Defaults to false (messages will not survive a broker restart) * `max_keepalive` - defaults to 65535 and, from version 2.0.12, `SetKeepAlive(0)` will result in a rejected connection by default. +* `token.Wait()` - Will return successfully before a message has been delivered if the client needs to reconnect to the broker before the message has been delivered. Reporting bugs -------------- diff --git a/token.go b/token.go index 996ab5b0..18feb5f6 100644 --- a/token.go +++ b/token.go @@ -37,12 +37,18 @@ type PacketAndToken struct { type Token interface { // Wait will wait indefinitely for the Token to complete, ie the Publish // to be sent and confirmed receipt from the broker. + // + // Note that, for backward compatibility, if the client reconnects to the + // broker Wait() will return before the message is delivered Wait() bool // WaitTimeout takes a time.Duration to wait for the flow associated with the // Token to complete, returns true if it returned before the timeout or // returns false if the timeout occurred. In the case of a timeout the Token // does not have an error set in case the caller wishes to wait again. + // + // Note that, for backward compatibility, if the client reconnects to the + // broker Wait() will return before the message is delivered WaitTimeout(time.Duration) bool // Done returns a channel that is closed when the flow associated @@ -51,6 +57,9 @@ type Token interface { // // Done is provided for use in select statements. Simple use cases may // use Wait or WaitTimeout. + // + // Note that, for backward compatibility, if the client reconnects to the + // broker Wait() will return before the message is delivered Done() <-chan struct{} Error() error