Documentation ¶
Overview ¶
Package protocols is a generated GoMock package.
Package protocols is a generated GoMock package.
Index ¶
- Constants
- Variables
- type MQTTClient
- type MQTTMessage
- type MQTTToken
- type MockMQTTClient
- func (m *MockMQTTClient) AddRoute(arg0 string, arg1 paho_mqtt_golang.MessageHandler)
- func (m *MockMQTTClient) Connect() paho_mqtt_golang.Token
- func (m *MockMQTTClient) Disconnect(arg0 uint)
- func (m *MockMQTTClient) EXPECT() *MockMQTTClientMockRecorder
- func (m *MockMQTTClient) IsConnected() bool
- func (m *MockMQTTClient) IsConnectionOpen() bool
- func (m *MockMQTTClient) OptionsReader() paho_mqtt_golang.ClientOptionsReader
- func (m *MockMQTTClient) Publish(arg0 string, arg1 byte, arg2 bool, arg3 interface{}) paho_mqtt_golang.Token
- func (m *MockMQTTClient) Subscribe(arg0 string, arg1 byte, arg2 paho_mqtt_golang.MessageHandler) paho_mqtt_golang.Token
- func (m *MockMQTTClient) SubscribeMultiple(arg0 map[string]byte, arg1 paho_mqtt_golang.MessageHandler) paho_mqtt_golang.Token
- func (m *MockMQTTClient) Unsubscribe(arg0 ...string) paho_mqtt_golang.Token
- type MockMQTTClientMockRecorder
- func (mr *MockMQTTClientMockRecorder) AddRoute(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockMQTTClientMockRecorder) Connect() *gomock.Call
- func (mr *MockMQTTClientMockRecorder) Disconnect(arg0 interface{}) *gomock.Call
- func (mr *MockMQTTClientMockRecorder) IsConnected() *gomock.Call
- func (mr *MockMQTTClientMockRecorder) IsConnectionOpen() *gomock.Call
- func (mr *MockMQTTClientMockRecorder) OptionsReader() *gomock.Call
- func (mr *MockMQTTClientMockRecorder) Publish(arg0, arg1, arg2, arg3 interface{}) *gomock.Call
- func (mr *MockMQTTClientMockRecorder) Subscribe(arg0, arg1, arg2 interface{}) *gomock.Call
- func (mr *MockMQTTClientMockRecorder) SubscribeMultiple(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockMQTTClientMockRecorder) Unsubscribe(arg0 ...interface{}) *gomock.Call
- type MockMQTTMessage
- func (m *MockMQTTMessage) Ack()
- func (m *MockMQTTMessage) Duplicate() bool
- func (m *MockMQTTMessage) EXPECT() *MockMQTTMessageMockRecorder
- func (m *MockMQTTMessage) MessageID() uint16
- func (m *MockMQTTMessage) Payload() []byte
- func (m *MockMQTTMessage) Qos() byte
- func (m *MockMQTTMessage) Retained() bool
- func (m *MockMQTTMessage) Topic() string
- type MockMQTTMessageMockRecorder
- func (mr *MockMQTTMessageMockRecorder) Ack() *gomock.Call
- func (mr *MockMQTTMessageMockRecorder) Duplicate() *gomock.Call
- func (mr *MockMQTTMessageMockRecorder) MessageID() *gomock.Call
- func (mr *MockMQTTMessageMockRecorder) Payload() *gomock.Call
- func (mr *MockMQTTMessageMockRecorder) Qos() *gomock.Call
- func (mr *MockMQTTMessageMockRecorder) Retained() *gomock.Call
- func (mr *MockMQTTMessageMockRecorder) Topic() *gomock.Call
- type MockMQTTToken
- type MockMQTTTokenMockRecorder
- type MockPubSubClient
- func (m *MockPubSubClient) Connect() error
- func (m *MockPubSubClient) Disconnect() error
- func (m *MockPubSubClient) EXPECT() *MockPubSubClientMockRecorder
- func (m *MockPubSubClient) Publish(arg0 context.Context, arg1 []byte, arg2 models.Client, arg3 byte) error
- func (m *MockPubSubClient) SubscribeToTopic(arg0 context.Context, arg1 string) error
- func (m *MockPubSubClient) SubscribeToTopics(arg0 context.Context, arg1 []string) error
- func (m *MockPubSubClient) UnsubscribeFromTopic(arg0 context.Context, arg1 string) error
- func (m *MockPubSubClient) ValidateTopic(arg0 string) error
- type MockPubSubClientMockRecorder
- func (mr *MockPubSubClientMockRecorder) Connect() *gomock.Call
- func (mr *MockPubSubClientMockRecorder) Disconnect() *gomock.Call
- func (mr *MockPubSubClientMockRecorder) Publish(arg0, arg1, arg2, arg3 interface{}) *gomock.Call
- func (mr *MockPubSubClientMockRecorder) SubscribeToTopic(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockPubSubClientMockRecorder) SubscribeToTopics(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockPubSubClientMockRecorder) UnsubscribeFromTopic(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockPubSubClientMockRecorder) ValidateTopic(arg0 interface{}) *gomock.Call
- type PubSubClient
- func NewGCPClient(cfg config.GCPCfg, logger log.FieldLogger) PubSubClient
- func NewKafkaPubSubClient(cfg config.KafkaCfg, logger log.FieldLogger, monitor analytics.MessageMonitor) PubSubClient
- func NewMQTTPubSubClient(cfg config.MQTTCfg, logger log.FieldLogger, monitor analytics.MessageMonitor) PubSubClient
Constants ¶
const ( QoSAtMostOnce = byte(0) QosAtLeastOnce = byte(1) QoSExactlyOnce = byte(2) )
List of MQTT availabe QoS
Variables ¶
var ( // ErrAlreadyConnected is returned when trying to connect an already connected client ErrAlreadyConnected = errors.New("already connected") // ErrNotConnected is returned when trying to disconnect a not connected client ErrNotConnected = errors.New("not connected") // ErrInvalidTopic is returned when a topic contains invalid characters ErrInvalidTopic = errors.New("topic has an invalid format") )
var ( // ErrMQTTTimeout is returned when the response from the mqtt broker timeout ErrMQTTTimeout = errors.New("mqtt timed out") )
Functions ¶
This section is empty.
Types ¶
type MQTTClient ¶
MQTTClient defines a minimal mqtt.Client needed to support E4 protocol
type MQTTMessage ¶
MQTTMessage wrap around a mqtt.Message
type MockMQTTClient ¶
type MockMQTTClient struct {
// contains filtered or unexported fields
}
MockMQTTClient is a mock of MQTTClient interface
func NewMockMQTTClient ¶
func NewMockMQTTClient(ctrl *gomock.Controller) *MockMQTTClient
NewMockMQTTClient creates a new mock instance
func (*MockMQTTClient) AddRoute ¶
func (m *MockMQTTClient) AddRoute(arg0 string, arg1 paho_mqtt_golang.MessageHandler)
AddRoute mocks base method
func (*MockMQTTClient) Connect ¶
func (m *MockMQTTClient) Connect() paho_mqtt_golang.Token
Connect mocks base method
func (*MockMQTTClient) Disconnect ¶
func (m *MockMQTTClient) Disconnect(arg0 uint)
Disconnect mocks base method
func (*MockMQTTClient) EXPECT ¶
func (m *MockMQTTClient) EXPECT() *MockMQTTClientMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockMQTTClient) IsConnected ¶
func (m *MockMQTTClient) IsConnected() bool
IsConnected mocks base method
func (*MockMQTTClient) IsConnectionOpen ¶
func (m *MockMQTTClient) IsConnectionOpen() bool
IsConnectionOpen mocks base method
func (*MockMQTTClient) OptionsReader ¶
func (m *MockMQTTClient) OptionsReader() paho_mqtt_golang.ClientOptionsReader
OptionsReader mocks base method
func (*MockMQTTClient) Publish ¶
func (m *MockMQTTClient) Publish(arg0 string, arg1 byte, arg2 bool, arg3 interface{}) paho_mqtt_golang.Token
Publish mocks base method
func (*MockMQTTClient) Subscribe ¶
func (m *MockMQTTClient) Subscribe(arg0 string, arg1 byte, arg2 paho_mqtt_golang.MessageHandler) paho_mqtt_golang.Token
Subscribe mocks base method
func (*MockMQTTClient) SubscribeMultiple ¶
func (m *MockMQTTClient) SubscribeMultiple(arg0 map[string]byte, arg1 paho_mqtt_golang.MessageHandler) paho_mqtt_golang.Token
SubscribeMultiple mocks base method
func (*MockMQTTClient) Unsubscribe ¶
func (m *MockMQTTClient) Unsubscribe(arg0 ...string) paho_mqtt_golang.Token
Unsubscribe mocks base method
type MockMQTTClientMockRecorder ¶
type MockMQTTClientMockRecorder struct {
// contains filtered or unexported fields
}
MockMQTTClientMockRecorder is the mock recorder for MockMQTTClient
func (*MockMQTTClientMockRecorder) AddRoute ¶
func (mr *MockMQTTClientMockRecorder) AddRoute(arg0, arg1 interface{}) *gomock.Call
AddRoute indicates an expected call of AddRoute
func (*MockMQTTClientMockRecorder) Connect ¶
func (mr *MockMQTTClientMockRecorder) Connect() *gomock.Call
Connect indicates an expected call of Connect
func (*MockMQTTClientMockRecorder) Disconnect ¶
func (mr *MockMQTTClientMockRecorder) Disconnect(arg0 interface{}) *gomock.Call
Disconnect indicates an expected call of Disconnect
func (*MockMQTTClientMockRecorder) IsConnected ¶
func (mr *MockMQTTClientMockRecorder) IsConnected() *gomock.Call
IsConnected indicates an expected call of IsConnected
func (*MockMQTTClientMockRecorder) IsConnectionOpen ¶
func (mr *MockMQTTClientMockRecorder) IsConnectionOpen() *gomock.Call
IsConnectionOpen indicates an expected call of IsConnectionOpen
func (*MockMQTTClientMockRecorder) OptionsReader ¶
func (mr *MockMQTTClientMockRecorder) OptionsReader() *gomock.Call
OptionsReader indicates an expected call of OptionsReader
func (*MockMQTTClientMockRecorder) Publish ¶
func (mr *MockMQTTClientMockRecorder) Publish(arg0, arg1, arg2, arg3 interface{}) *gomock.Call
Publish indicates an expected call of Publish
func (*MockMQTTClientMockRecorder) Subscribe ¶
func (mr *MockMQTTClientMockRecorder) Subscribe(arg0, arg1, arg2 interface{}) *gomock.Call
Subscribe indicates an expected call of Subscribe
func (*MockMQTTClientMockRecorder) SubscribeMultiple ¶
func (mr *MockMQTTClientMockRecorder) SubscribeMultiple(arg0, arg1 interface{}) *gomock.Call
SubscribeMultiple indicates an expected call of SubscribeMultiple
func (*MockMQTTClientMockRecorder) Unsubscribe ¶
func (mr *MockMQTTClientMockRecorder) Unsubscribe(arg0 ...interface{}) *gomock.Call
Unsubscribe indicates an expected call of Unsubscribe
type MockMQTTMessage ¶
type MockMQTTMessage struct {
// contains filtered or unexported fields
}
MockMQTTMessage is a mock of MQTTMessage interface
func NewMockMQTTMessage ¶
func NewMockMQTTMessage(ctrl *gomock.Controller) *MockMQTTMessage
NewMockMQTTMessage creates a new mock instance
func (*MockMQTTMessage) Duplicate ¶
func (m *MockMQTTMessage) Duplicate() bool
Duplicate mocks base method
func (*MockMQTTMessage) EXPECT ¶
func (m *MockMQTTMessage) EXPECT() *MockMQTTMessageMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockMQTTMessage) MessageID ¶
func (m *MockMQTTMessage) MessageID() uint16
MessageID mocks base method
func (*MockMQTTMessage) Payload ¶
func (m *MockMQTTMessage) Payload() []byte
Payload mocks base method
func (*MockMQTTMessage) Retained ¶
func (m *MockMQTTMessage) Retained() bool
Retained mocks base method
type MockMQTTMessageMockRecorder ¶
type MockMQTTMessageMockRecorder struct {
// contains filtered or unexported fields
}
MockMQTTMessageMockRecorder is the mock recorder for MockMQTTMessage
func (*MockMQTTMessageMockRecorder) Ack ¶
func (mr *MockMQTTMessageMockRecorder) Ack() *gomock.Call
Ack indicates an expected call of Ack
func (*MockMQTTMessageMockRecorder) Duplicate ¶
func (mr *MockMQTTMessageMockRecorder) Duplicate() *gomock.Call
Duplicate indicates an expected call of Duplicate
func (*MockMQTTMessageMockRecorder) MessageID ¶
func (mr *MockMQTTMessageMockRecorder) MessageID() *gomock.Call
MessageID indicates an expected call of MessageID
func (*MockMQTTMessageMockRecorder) Payload ¶
func (mr *MockMQTTMessageMockRecorder) Payload() *gomock.Call
Payload indicates an expected call of Payload
func (*MockMQTTMessageMockRecorder) Qos ¶
func (mr *MockMQTTMessageMockRecorder) Qos() *gomock.Call
Qos indicates an expected call of Qos
func (*MockMQTTMessageMockRecorder) Retained ¶
func (mr *MockMQTTMessageMockRecorder) Retained() *gomock.Call
Retained indicates an expected call of Retained
func (*MockMQTTMessageMockRecorder) Topic ¶
func (mr *MockMQTTMessageMockRecorder) Topic() *gomock.Call
Topic indicates an expected call of Topic
type MockMQTTToken ¶
type MockMQTTToken struct {
// contains filtered or unexported fields
}
MockMQTTToken is a mock of MQTTToken interface
func NewMockMQTTToken ¶
func NewMockMQTTToken(ctrl *gomock.Controller) *MockMQTTToken
NewMockMQTTToken creates a new mock instance
func (*MockMQTTToken) EXPECT ¶
func (m *MockMQTTToken) EXPECT() *MockMQTTTokenMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockMQTTToken) WaitTimeout ¶
func (m *MockMQTTToken) WaitTimeout(arg0 time.Duration) bool
WaitTimeout mocks base method
type MockMQTTTokenMockRecorder ¶
type MockMQTTTokenMockRecorder struct {
// contains filtered or unexported fields
}
MockMQTTTokenMockRecorder is the mock recorder for MockMQTTToken
func (*MockMQTTTokenMockRecorder) Error ¶
func (mr *MockMQTTTokenMockRecorder) Error() *gomock.Call
Error indicates an expected call of Error
func (*MockMQTTTokenMockRecorder) Wait ¶
func (mr *MockMQTTTokenMockRecorder) Wait() *gomock.Call
Wait indicates an expected call of Wait
func (*MockMQTTTokenMockRecorder) WaitTimeout ¶
func (mr *MockMQTTTokenMockRecorder) WaitTimeout(arg0 interface{}) *gomock.Call
WaitTimeout indicates an expected call of WaitTimeout
type MockPubSubClient ¶
type MockPubSubClient struct {
// contains filtered or unexported fields
}
MockPubSubClient is a mock of PubSubClient interface
func NewMockPubSubClient ¶
func NewMockPubSubClient(ctrl *gomock.Controller) *MockPubSubClient
NewMockPubSubClient creates a new mock instance
func (*MockPubSubClient) Connect ¶
func (m *MockPubSubClient) Connect() error
Connect mocks base method
func (*MockPubSubClient) Disconnect ¶
func (m *MockPubSubClient) Disconnect() error
Disconnect mocks base method
func (*MockPubSubClient) EXPECT ¶
func (m *MockPubSubClient) EXPECT() *MockPubSubClientMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockPubSubClient) Publish ¶
func (m *MockPubSubClient) Publish(arg0 context.Context, arg1 []byte, arg2 models.Client, arg3 byte) error
Publish mocks base method
func (*MockPubSubClient) SubscribeToTopic ¶
func (m *MockPubSubClient) SubscribeToTopic(arg0 context.Context, arg1 string) error
SubscribeToTopic mocks base method
func (*MockPubSubClient) SubscribeToTopics ¶
func (m *MockPubSubClient) SubscribeToTopics(arg0 context.Context, arg1 []string) error
SubscribeToTopics mocks base method
func (*MockPubSubClient) UnsubscribeFromTopic ¶
func (m *MockPubSubClient) UnsubscribeFromTopic(arg0 context.Context, arg1 string) error
UnsubscribeFromTopic mocks base method
func (*MockPubSubClient) ValidateTopic ¶
func (m *MockPubSubClient) ValidateTopic(arg0 string) error
ValidateTopic mocks base method
type MockPubSubClientMockRecorder ¶
type MockPubSubClientMockRecorder struct {
// contains filtered or unexported fields
}
MockPubSubClientMockRecorder is the mock recorder for MockPubSubClient
func (*MockPubSubClientMockRecorder) Connect ¶
func (mr *MockPubSubClientMockRecorder) Connect() *gomock.Call
Connect indicates an expected call of Connect
func (*MockPubSubClientMockRecorder) Disconnect ¶
func (mr *MockPubSubClientMockRecorder) Disconnect() *gomock.Call
Disconnect indicates an expected call of Disconnect
func (*MockPubSubClientMockRecorder) Publish ¶
func (mr *MockPubSubClientMockRecorder) Publish(arg0, arg1, arg2, arg3 interface{}) *gomock.Call
Publish indicates an expected call of Publish
func (*MockPubSubClientMockRecorder) SubscribeToTopic ¶
func (mr *MockPubSubClientMockRecorder) SubscribeToTopic(arg0, arg1 interface{}) *gomock.Call
SubscribeToTopic indicates an expected call of SubscribeToTopic
func (*MockPubSubClientMockRecorder) SubscribeToTopics ¶
func (mr *MockPubSubClientMockRecorder) SubscribeToTopics(arg0, arg1 interface{}) *gomock.Call
SubscribeToTopics indicates an expected call of SubscribeToTopics
func (*MockPubSubClientMockRecorder) UnsubscribeFromTopic ¶
func (mr *MockPubSubClientMockRecorder) UnsubscribeFromTopic(arg0, arg1 interface{}) *gomock.Call
UnsubscribeFromTopic indicates an expected call of UnsubscribeFromTopic
func (*MockPubSubClientMockRecorder) ValidateTopic ¶
func (mr *MockPubSubClientMockRecorder) ValidateTopic(arg0 interface{}) *gomock.Call
ValidateTopic indicates an expected call of ValidateTopic
type PubSubClient ¶
type PubSubClient interface { Connect() error Disconnect() error SubscribeToTopics(ctx context.Context, topics []string) error SubscribeToTopic(ctx context.Context, topic string) error UnsubscribeFromTopic(ctx context.Context, topic string) error Publish(ctx context.Context, payload []byte, client models.Client, qos byte) error // ValidateTopic allows to check a given topic against a specific implementation // and returns an error if the given topic is not acceptable on the current PubSubClient. ValidateTopic(topic string) error }
PubSubClient defines a publish / subscribe client interface for the E4 service.
func NewGCPClient ¶
func NewGCPClient(cfg config.GCPCfg, logger log.FieldLogger) PubSubClient
NewGCPClient returns a new PubSubClient able to interact with GCP IoT Core apis Currently only support authorizing the client using Application Default Credentials. See https://g.co/dv/identity/protocols/application-default-credentials TLDR: run `gcloud auth login` on the host running the C2, then start the C2.
TODO: better auth
Only the Publish method is implemented, to send commands to devices. Other features, such as topic subscription and un-subscription, are not available due to GCP restrictions, and are just no-op.
func NewKafkaPubSubClient ¶
func NewKafkaPubSubClient(cfg config.KafkaCfg, logger log.FieldLogger, monitor analytics.MessageMonitor) PubSubClient
NewKafkaPubSubClient creates a new PubSubClient backed by Kafka
func NewMQTTPubSubClient ¶
func NewMQTTPubSubClient( cfg config.MQTTCfg, logger log.FieldLogger, monitor analytics.MessageMonitor, ) PubSubClient
NewMQTTPubSubClient creates and connect a new PubSubClient over MQTT