mirror of
https://github.com/go-mqtt/mqtt.git
synced 2025-08-10 10:02:58 +03:00
Nonfunctional code reorder.
This commit is contained in:
@@ -11,19 +11,6 @@ import (
|
|||||||
"github.com/pascaldekloe/mqtt"
|
"github.com/pascaldekloe/mqtt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewPublishStub returns a new stub for mqtt.Client Publish with a fixed return
|
|
||||||
// value.
|
|
||||||
func NewPublishStub(returnFix error) func(quit <-chan struct{}, message []byte, topic string) error {
|
|
||||||
return func(quit <-chan struct{}, message []byte, topic string) error {
|
|
||||||
select {
|
|
||||||
case <-quit:
|
|
||||||
return mqtt.ErrCanceled
|
|
||||||
default:
|
|
||||||
return returnFix
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Transfer defines a message exchange.
|
// Transfer defines a message exchange.
|
||||||
type Transfer struct {
|
type Transfer struct {
|
||||||
Message []byte // payload
|
Message []byte // payload
|
||||||
@@ -95,6 +82,19 @@ func NewPublishMock(t testing.TB, want ...Transfer) func(quit <-chan struct{}, m
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewPublishStub returns a new stub for mqtt.Client Publish with a fixed return
|
||||||
|
// value.
|
||||||
|
func NewPublishStub(returnFix error) func(quit <-chan struct{}, message []byte, topic string) error {
|
||||||
|
return func(quit <-chan struct{}, message []byte, topic string) error {
|
||||||
|
select {
|
||||||
|
case <-quit:
|
||||||
|
return mqtt.ErrCanceled
|
||||||
|
default:
|
||||||
|
return returnFix
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// AckBlock prevents ack <-chan error submission.
|
// AckBlock prevents ack <-chan error submission.
|
||||||
type AckBlock struct {
|
type AckBlock struct {
|
||||||
Delay time.Duration // zero defaults to indefinite
|
Delay time.Duration // zero defaults to indefinite
|
||||||
|
Reference in New Issue
Block a user