Skip to content

Commit

Permalink
reply review
Browse files Browse the repository at this point in the history
Signed-off-by: myan <[email protected]>
  • Loading branch information
yanmxa committed Sep 12, 2024
1 parent 8c99358 commit 67112a9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
15 changes: 1 addition & 14 deletions pkg/cloudevents/generic/options/mqtt/agentoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (o *mqttAgentOptions) Protocol(ctx context.Context) (options.CloudEventsPro

// receiving status resync events from all sources
if len(o.Topics.SourceBroadcast) != 0 {
subscribe.Subscriptions = appendSubscriptions(subscribe.Subscriptions, paho.SubscribeOptions{
subscribe.Subscriptions = append(subscribe.Subscriptions, paho.SubscribeOptions{
Topic: o.Topics.SourceBroadcast,
QoS: byte(o.SubQoS),
})
Expand All @@ -116,16 +116,3 @@ func (o *mqttAgentOptions) Protocol(ctx context.Context) (options.CloudEventsPro
func (o *mqttAgentOptions) ErrorChan() <-chan error {
return o.errorChan
}

func appendSubscriptions(options []paho.SubscribeOptions, option paho.SubscribeOptions) []paho.SubscribeOptions {
exist := false
for _, sub := range options {
if sub.Topic == option.Topic {
exist = true
}
}
if !exist {
options = append(options, option)
}
return options
}
2 changes: 1 addition & 1 deletion pkg/cloudevents/generic/options/mqtt/sourceoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (o *mqttSourceOptions) Protocol(ctx context.Context) (options.CloudEventsPr

if len(o.Topics.AgentBroadcast) != 0 {
// receiving spec resync events from all agents
subscribe.Subscriptions = appendSubscriptions(subscribe.Subscriptions, paho.SubscribeOptions{
subscribe.Subscriptions = append(subscribe.Subscriptions, paho.SubscribeOptions{
Topic: o.Topics.AgentBroadcast,
QoS: byte(o.SubQoS),
})
Expand Down

0 comments on commit 67112a9

Please sign in to comment.