Documentation
¶
Index ¶
- type HostInfo
- type MessageBusConfig
- type MessageEnvelope
- func NewMessageEnvelope(payload []byte, ctx context.Context) MessageEnvelope
- func NewMessageEnvelopeForRequest(payload []byte, queryParams map[string]string) MessageEnvelope
- func NewMessageEnvelopeForResponse(payload []byte, requestId string, correlationId string, contentType string) (MessageEnvelope, error)
- func NewMessageEnvelopeFromJSON(message []byte) (MessageEnvelope, error)
- func NewMessageEnvelopeWithError(requestId string, errorMessage string) MessageEnvelope
- type TopicChannel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HostInfo ¶
type HostInfo struct {
// Host is the hostname or IP address of the messaging broker, if applicable.
Host string
// Port defines the port on which to access the message queue.
Port int
// Protocol indicates the protocol to use when accessing the message queue.
Protocol string
}
HostInfo is the URL information of the host as the following scheme: <Protocol>://<Broker>:<Port>
func (*HostInfo) GetHostURL ¶
GetHostURL returns the complete URL for the host-info configuration
func (*HostInfo) IsHostInfoEmpty ¶
IsHostInfoEmpty returns whether the host-info has been initialized or not
type MessageBusConfig ¶
type MessageBusConfig struct {
// Broker contains the connection information for publishing and subscribing to the broker for the EdgeX MessageBus
Broker HostInfo
// Type indicates the message queue platform being used. eg. "redis" for Redis Pub/Sub
Type string
// Optional contains all other properties of message bus that are specific to
// certain concrete implementations like MQTT's QoS, for example.
Optional map[string]string
}
MessageBusConfig defines the messaging information need to connect to the message bus in a publish-subscribe pattern
type MessageEnvelope ¶
type MessageEnvelope struct {
// ApiVersion (from Versionable) shows the API version for the message envelope.
commonDTO.Versionable
// ReceivedTopic is the topic that the message was received on.
ReceivedTopic string `json:"receivedTopic"`
// CorrelationID is an object id to identify the envelope.
CorrelationID string `json:"correlationID"`
// RequestID is an object id to identify the request.
RequestID string `json:"requestID"`
// ErrorCode provides the indication of error. '0' indicates no error, '1' indicates error.
// Additional codes may be added in the future. If non-0, the payload will contain the error.
ErrorCode int `json:"errorCode"`
// Payload is byte representation of the data being transferred.
Payload []byte `json:"payload"`
// ContentType is the marshaled type of payload, i.e. application/json, application/xml, application/cbor, etc
ContentType string `json:"contentType"`
// QueryParams is optionally provided key/value pairs.
QueryParams map[string]string `json:"queryParams,omitempty"`
}
MessageEnvelope is the data structure for messages. It wraps the generic message payload with attributes.
func NewMessageEnvelope ¶
func NewMessageEnvelope(payload []byte, ctx context.Context) MessageEnvelope
NewMessageEnvelope creates a new MessageEnvelope for the specified payload with attributes from the specified context
func NewMessageEnvelopeForRequest ¶
func NewMessageEnvelopeForRequest(payload []byte, queryParams map[string]string) MessageEnvelope
NewMessageEnvelopeForRequest creates a new MessageEnvelope for sending request to EdgeX via internal MessageBus to target Device Service. Used when request is from internal App Service via command client.
func NewMessageEnvelopeForResponse ¶
func NewMessageEnvelopeForResponse(payload []byte, requestId string, correlationId string, contentType string) (MessageEnvelope, error)
NewMessageEnvelopeForResponse creates a new MessageEnvelope for sending response from Device Service back to Core Command.
func NewMessageEnvelopeFromJSON ¶
func NewMessageEnvelopeFromJSON(message []byte) (MessageEnvelope, error)
NewMessageEnvelopeFromJSON creates a new MessageEnvelope by decoding the message payload received from external MQTT in order to send request via internal MessageBus.
func NewMessageEnvelopeWithError ¶
func NewMessageEnvelopeWithError(requestId string, errorMessage string) MessageEnvelope
NewMessageEnvelopeWithError creates a new MessageEnvelope with ErrorCode set to 1 indicating there's error and the payload contains message string about the error.
type TopicChannel ¶
type TopicChannel struct {
// Topic for subscriber to filter on if any
Topic string
// Messages is the returned message channel for the subscriber
Messages chan MessageEnvelope
}
TopicChannel is the data structure for subscriber