-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
provide the qos and retain configuration for mqtt protocol
Signed-off-by: myan <myan@redhat.com> to review Signed-off-by: myan <myan@redhat.com> avoid all-or-nothing Signed-off-by: myan <myan@redhat.com> rollback all-or-nothing Signed-off-by: myan <myan@redhat.com> convert tparamter to pointers Signed-off-by: myan <myan@redhat.com> fixed doc string Signed-off-by: myan <myan@redhat.com> remove the protocolContext Signed-off-by: myan <myan@redhat.com> add context for protocol Signed-off-by: myan <myan@redhat.com> initialize mqtt protocol with publish/subscribe options Signed-off-by: myan <myan@redhat.com> remove the sender options from context Signed-off-by: myan <myan@redhat.com> using functional options in new() Signed-off-by: myan <myan@redhat.com> add ctx to the new() function Signed-off-by: myan <myan@redhat.com>
- Loading branch information
Showing
6 changed files
with
157 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
Copyright 2023 The CloudEvents Authors | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package mqtt_paho | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/eclipse/paho.golang/paho" | ||
) | ||
|
||
// Option is the function signature required to be considered an mqtt_paho.Option. | ||
type Option func(*Protocol) error | ||
|
||
// WithConnect sets the paho.Connect configuration for the client. This option is not required. | ||
func WithConnect(connOpt *paho.Connect) Option { | ||
return func(p *Protocol) error { | ||
if connOpt == nil { | ||
return fmt.Errorf("the paho.Connect option must not be nil") | ||
} | ||
p.connOption = connOpt | ||
return nil | ||
} | ||
} | ||
|
||
// WithPublish sets the paho.Publish configuration for the client. This option is required if you want to send messages. | ||
func WithPublish(publishOpt *paho.Publish) Option { | ||
return func(p *Protocol) error { | ||
if publishOpt == nil { | ||
return fmt.Errorf("the paho.Publish option must not be nil") | ||
} | ||
p.publishOption = publishOpt | ||
return nil | ||
} | ||
} | ||
|
||
// WithSubscribe sets the paho.Subscribe configuration for the client. This option is required if you want to receive messages. | ||
func WithSubscribe(subscribeOpt *paho.Subscribe) Option { | ||
return func(p *Protocol) error { | ||
if subscribeOpt == nil { | ||
return fmt.Errorf("the paho.Subscribe option must not be nil") | ||
} | ||
p.subscribeOption = subscribeOpt | ||
return nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters