Skip to content

Commit

Permalink
remove the sender options from context
Browse files Browse the repository at this point in the history
Signed-off-by: myan <[email protected]>
  • Loading branch information
yanmxa committed Jul 28, 2023
1 parent 188a389 commit d3ae386
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 36 deletions.
29 changes: 0 additions & 29 deletions protocol/mqtt_paho/v2/context.go

This file was deleted.

5 changes: 0 additions & 5 deletions protocol/mqtt_paho/v2/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ func (t *Protocol) Send(ctx context.Context, m binding.Message, transformers ...
cecontext.WithTopic(ctx, "")
}

if PublishOptionFrom(ctx) != nil {
msg = PublishOptionFrom(ctx)
ctx = WithPublishOption(ctx, nil)
}

err = WritePubMessage(ctx, m, msg, transformers...)
if err != nil {
return err
Expand Down
3 changes: 2 additions & 1 deletion samples/mqtt/sender/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/google/uuid"

mqtt_paho "github.com/cloudevents/sdk-go/protocol/mqtt_paho/v2"
cecontext "github.com/cloudevents/sdk-go/v2/context"
)

const (
Expand Down Expand Up @@ -63,7 +64,7 @@ func main() {
log.Printf("failed to set data: %v", err)
}
if result := c.Send(
mqtt_paho.WithPublishOption(ctx, &paho.Publish{Topic: "test-topic", QoS: 0, Retain: false}),
cecontext.WithTopic(ctx, "test-topic"),
e,
); cloudevents.IsUndelivered(result) {
log.Printf("failed to send: %v", result)
Expand Down
3 changes: 2 additions & 1 deletion test/integration/mqtt_paho/mqtt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (

mqtt_paho "github.com/cloudevents/sdk-go/protocol/mqtt_paho/v2"
cloudevents "github.com/cloudevents/sdk-go/v2"
cecontext "github.com/cloudevents/sdk-go/v2/context"
"github.com/cloudevents/sdk-go/v2/event"
"github.com/cloudevents/sdk-go/v2/test"
)
Expand Down Expand Up @@ -68,7 +69,7 @@ func TestSendEvent(t *testing.T) {
return
case <-timer.C:
result := client.Send(
mqtt_paho.WithPublishOption(ctx, &paho.Publish{Topic: topicName, QoS: 0, Retain: false}),
cecontext.WithTopic(ctx, topicName),
inEvent,
)
require.NoError(t, result)
Expand Down

0 comments on commit d3ae386

Please sign in to comment.