Upgrade dependencies
This commit is contained in:
36
vendor/github.com/eclipse/paho.mqtt.golang/token.go
generated
vendored
36
vendor/github.com/eclipse/paho.mqtt.golang/token.go
generated
vendored
@ -31,8 +31,24 @@ type PacketAndToken struct {
|
||||
// Token defines the interface for the tokens used to indicate when
|
||||
// actions have completed.
|
||||
type Token interface {
|
||||
// Wait will wait indefinitely for the Token to complete, ie the Publish
|
||||
// to be sent and confirmed receipt from the broker.
|
||||
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.
|
||||
WaitTimeout(time.Duration) bool
|
||||
|
||||
// Done returns a channel that is closed when the flow associated
|
||||
// with the Token completes. Clients should call Error after the
|
||||
// channel is closed to check if the flow completed successfully.
|
||||
//
|
||||
// Done is provided for use in select statements. Simple use cases may
|
||||
// use Wait or WaitTimeout.
|
||||
Done() <-chan struct{}
|
||||
|
||||
Error() error
|
||||
}
|
||||
|
||||
@ -52,21 +68,14 @@ type baseToken struct {
|
||||
err error
|
||||
}
|
||||
|
||||
// Wait will wait indefinitely for the Token to complete, ie the Publish
|
||||
// to be sent and confirmed receipt from the broker
|
||||
// Wait implements the Token Wait method.
|
||||
func (b *baseToken) Wait() bool {
|
||||
<-b.complete
|
||||
return true
|
||||
}
|
||||
|
||||
// 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
|
||||
// WaitTimeout implements the Token WaitTimeout method.
|
||||
func (b *baseToken) WaitTimeout(d time.Duration) bool {
|
||||
b.m.Lock()
|
||||
defer b.m.Unlock()
|
||||
|
||||
timer := time.NewTimer(d)
|
||||
select {
|
||||
case <-b.complete:
|
||||
@ -80,6 +89,11 @@ func (b *baseToken) WaitTimeout(d time.Duration) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Done implements the Token Done method.
|
||||
func (b *baseToken) Done() <-chan struct{} {
|
||||
return b.complete
|
||||
}
|
||||
|
||||
func (b *baseToken) flowComplete() {
|
||||
select {
|
||||
case <-b.complete:
|
||||
@ -125,7 +139,7 @@ type ConnectToken struct {
|
||||
sessionPresent bool
|
||||
}
|
||||
|
||||
// ReturnCode returns the acknowlegement code in the connack sent
|
||||
// ReturnCode returns the acknowledgement code in the connack sent
|
||||
// in response to a Connect()
|
||||
func (c *ConnectToken) ReturnCode() byte {
|
||||
c.m.RLock()
|
||||
@ -160,6 +174,7 @@ type SubscribeToken struct {
|
||||
baseToken
|
||||
subs []string
|
||||
subResult map[string]byte
|
||||
messageID uint16
|
||||
}
|
||||
|
||||
// Result returns a map of topics that were subscribed to along with
|
||||
@ -175,6 +190,7 @@ func (s *SubscribeToken) Result() map[string]byte {
|
||||
// required to provide information about calls to Unsubscribe()
|
||||
type UnsubscribeToken struct {
|
||||
baseToken
|
||||
messageID uint16
|
||||
}
|
||||
|
||||
// DisconnectToken is an extension of Token containing the extra fields
|
||||
|
Reference in New Issue
Block a user