types

package
v2.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2022 License: Apache-2.0 Imports: 5 Imported by: 18

Documentation

Index

Constants

View Source
const (
	ApiVersion      = "v2"
	CorrelationID   = "X-Correlation-ID"
	ContentType     = "Content-Type"
	ContentTypeJSON = "application/json"
	ContentTypeText = "text/plain"
)

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>://<Host>:<Port>

func (*HostInfo) GetHostURL

func (info *HostInfo) GetHostURL() string

GetHostURL returns the complete URL for the host-info configuration

func (*HostInfo) IsHostInfoEmpty

func (info *HostInfo) IsHostInfoEmpty() bool

IsHostInfoEmpty returns whether the host-info has been initialized or not

type MessageBusConfig

type MessageBusConfig struct {
	// PublishHost contains the connection information for a publishing on 0mq
	PublishHost HostInfo
	// SubscribeHost contains the connection information for a subscribing on 0mq
	SubscribeHost HostInfo
	// Type indicates the message queue platform being used. eg. "zero" for 0mq
	Type string
	// Optional contains all other properties of message bus that is specific to
	// certain concrete implementation 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 {
	// ReceivedTopic is the topic that the message was received on.
	ReceivedTopic string
	// CorrelationID is an object id to identify the envelope.
	CorrelationID string
	// ApiVersion shows the API version in message envelope.
	ApiVersion string
	// RequestID is an object id to identify the request.
	RequestID string
	// 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
	// Payload is byte representation of the data being transferred.
	Payload []byte
	// ContentType is the marshaled type of payload, i.e. application/json, application/xml, application/cbor, etc
	ContentType string
	// QueryParams is optionally provided key/value pairs.
	QueryParams map[string]string
}

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 added in v2.3.0

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 added in v2.3.0

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 added in v2.3.0

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 added in v2.3.0

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL