Documentation ¶
Index ¶
Constants ¶
const ( //PingCommandContentType is the content type for a ping command PingCommandContentType = "application/vnd-ping-command" //PongResponseContentType is the content type for a pong response PongResponseContentType = "application/vnd-pong-response" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommandHandler ¶
type CommandHandler func(CommandMessageWrapper) error
CommandHandler is a callback type to be used for dispatching incoming commands
func NewPingCommandHandler ¶
func NewPingCommandHandler(ctx Context) CommandHandler
NewPingCommandHandler returns a callback function to be called when ping commands are received
type CommandMessage ¶
type CommandMessage interface {
ContentType() string
}
CommandMessage is an interface used when sending commands
func NewPingCommand ¶
func NewPingCommand() CommandMessage
NewPingCommand instantiates a new ping command
func NewPongResponse ¶
func NewPongResponse(ping PingCommand) CommandMessage
NewPongResponse instantiates a new pong response from a ping command
type CommandMessageWrapper ¶
type CommandMessageWrapper interface { Body() []byte RespondWith(CommandMessage) error }
CommandMessageWrapper is used to wrap an incoming command message
type Config ¶
Config is an encapsulating context that wraps configuration information used by the initialization methods of the messaging library
func LoadConfiguration ¶
LoadConfiguration loads configuration values from RABBITMQ_HOST, RABBITMQ_USER and RABBITMQ_PASS. The username and password defaults to the bitnami ootb values for local testing.
type Context ¶
type Context interface { NoteToSelf(command CommandMessage) error SendCommandTo(command CommandMessage, key string) error SendResponseTo(response CommandMessage, key string) error PublishOnTopic(message TopicMessage) error Close() RegisterCommandHandler(contentType string, handler CommandHandler) error RegisterTopicMessageHandler(routingKey string, handler TopicMessageHandler) }
Context encapsulates the underlying messaging primitives, as well as their associated configuration
func Initialize ¶
Initialize takes a Config parameter and initializes a connection, channel, topic exchange, command exchange and service specific command and response queues. Retries every 2 seconds until successfull.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error encapsulates a lower level error together with an error message provided by the caller that experienced the error
type IoTHubMessage ¶
type IoTHubMessage struct { Origin IoTHubMessageOrigin `json:"origin"` Timestamp string `json:"timestamp"` }
type IoTHubMessageOrigin ¶
type PingCommand ¶
PingCommand is a utility command to check the messenger connection
func (PingCommand) ContentType ¶
func (cmd PingCommand) ContentType() string
ContentType returns the content type for a ping command
type PongResponse ¶
type PongResponse struct { Cmd string `json:"cmd"` PingSent time.Time Timestamp time.Time `json:"timestamp"` }
PongResponse is a utility response to check the messenger connection
func (PongResponse) ContentType ¶
func (cmd PongResponse) ContentType() string
ContentType returns the content type for a pong response
type TopicMessage ¶
TopicMessage is an interface used when sending messages to make sure that messages are sent to the correct topic with correct content type
type TopicMessageHandler ¶
TopicMessageHandler is a callback type that should be passed to RegisterTopicMessageHandler to receive messages from topics.