MQTT: make Monitor first-read cancellable via context (#31116)
This commit is contained in:
parent
aa7b5103dd
commit
2294066b27
4 changed files with 44 additions and 3 deletions
|
|
@ -1,11 +1,14 @@
|
|||
package plugin
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/evcc-io/evcc/plugin/pipeline"
|
||||
"github.com/evcc-io/evcc/util"
|
||||
)
|
||||
|
||||
type msgHandler struct {
|
||||
ctx context.Context
|
||||
topic string
|
||||
pipeline *pipeline.Pipeline
|
||||
val *util.Monitor[string]
|
||||
|
|
@ -17,7 +20,7 @@ func (h *msgHandler) receive(payload string) {
|
|||
|
||||
// hasValue returned the received and processed payload as string
|
||||
func (h *msgHandler) hasValue() (string, error) {
|
||||
payload, err := h.val.Get()
|
||||
payload, err := h.val.GetContext(h.ctx)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue