rabbit

package
v0.15.2 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitializeContext

func InitializeContext(ctx context.Context) context.Context

InitializeContext adds the rabbit session to the context. The new context is returned because context is immutable.

Types

type ContextKey

type ContextKey string

ContextKey defines a type to store the rabbit session in context.Context.

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger logs the HTTP request and response in a configurable file.

func GetLogger

func GetLogger() *Logger

GetLogger returns the logger for rabbit messages in publish/subscribe. If the logger is not created yet, it creates a new instance of Logger.

func NewLogger

func NewLogger(path string) (*Logger, error)

NewLogger creates an instance of the logger. It configures the file path where the RabbitMQ interactions are written.

func (Logger) LogPublishedMessage

func (l Logger) LogPublishedMessage(msg, topic, corr string)

LogPublishedMessage logs a rabbit message published to a topic.

func (Logger) LogReceivedMessage

func (l Logger) LogReceivedMessage(msg, topic, corr string)

LogReceivedMessage logs a rabbit message received from a topic.

func (Logger) LogSubscribedTopic

func (l Logger) LogSubscribedTopic(topic string)

LogSubscribedTopic logs the subscription to a rabbit topic.

type Session

type Session struct {
	Connection *amqp.Connection
	// Messages received from the publish/subscribe channel
	Messages []amqp.Delivery
	// Correlator is used to correlate the messages for a specific session
	Correlator string
	// contains filtered or unexported fields
}

Session contains the information of a rabbit session.

func GetSession

func GetSession(ctx context.Context) *Session

GetSession returns the rabbit session stored in context. Note that the context should be previously initialized with InitializeContext function.

func (*Session) ConfigureConnection

func (s *Session) ConfigureConnection(ctx context.Context, uri string) error

ConfigureConnection creates a rabbit connection based on the URI.

func (*Session) ConfigureHeaders

func (s *Session) ConfigureHeaders(ctx context.Context, headers map[string]interface{}) error

ConfigureHeaders stores a table of rabbit headers in the application context.

func (*Session) ConfigureStandardProperties

func (s *Session) ConfigureStandardProperties(ctx context.Context, props amqp.Publishing)

ConfigureStandardProperties stores a table of rabbit properties in the application context.

func (*Session) PublishJSONMessage

func (s *Session) PublishJSONMessage(ctx context.Context, topic string, props map[string]interface{}) error

PublishJSONMessage publishes a JSON message in a rabbit topic.

func (*Session) PublishTextMessage

func (s *Session) PublishTextMessage(ctx context.Context, topic, message string) error

PublishTextMessage publishes a text message in a rabbit topic.

func (*Session) SubscribeTopic

func (s *Session) SubscribeTopic(ctx context.Context, topic string) error

SubscribeTopic subscribes to a rabbit topic to receive messages via a channel.

func (*Session) Unsubscribe

func (s *Session) Unsubscribe(ctx context.Context) error

Unsubscribe unsubscribes from rabbit closing the channel associated. If this method is not invoked, then the goroutine created with SubscribeTopic is never closed and will permanently processing messages from the topic until the program is finished.

func (*Session) ValidateMessageHeaders

func (s *Session) ValidateMessageHeaders(ctx context.Context, headers map[string]interface{}) error

ValidateMessageHeaders checks if the message rabbit headers are equal the expected values.

func (*Session) ValidateMessageJSONBody

func (s *Session) ValidateMessageJSONBody(ctx context.Context, props map[string]interface{}, pos int) error

ValidateMessageJSONBody checks if the message json body properties of message in position 'pos' are equal the expected values. if pos == -1 then it means last message stored, that is the one stored in s.msg

func (*Session) ValidateMessageStandardProperties

func (s *Session) ValidateMessageStandardProperties(ctx context.Context, props amqp.Delivery) error

ValidateMessageStandardProperties checks if the message standard rabbit properties are equal the expected values.

func (*Session) ValidateMessageTextBody

func (s *Session) ValidateMessageTextBody(ctx context.Context, expectedMsg string) error

ValidateMessageTextBody checks if the message text body is equal to the expected value.

func (*Session) WaitForJSONMessageWithProperties

func (s *Session) WaitForJSONMessageWithProperties(ctx context.Context, timeout time.Duration, props map[string]interface{}) error

WaitForJSONMessageWithProperties waits up to timeout and verifies if there is a message received in the topic with the requested properties.

func (*Session) WaitForMessagesWithStandardProperties

func (s *Session) WaitForMessagesWithStandardProperties(ctx context.Context, timeout time.Duration, count int, props amqp.Delivery) error

WaitForMessagesWithStandardProperties waits for 'count' messages with standard rabbit properties that are equal to the expected values.

func (*Session) WaitForTextMessage

func (s *Session) WaitForTextMessage(ctx context.Context, timeout time.Duration, expectedMsg string) error

WaitForTextMessage waits up to timeout until the expected message is found in the received messages for this session.

type Steps

type Steps struct {
}

Steps to initialize common steps.

func (Steps) InitializeSteps

func (cs Steps) InitializeSteps(ctx context.Context, scenCtx *godog.ScenarioContext) context.Context

InitializeSteps initializes all the steps.

Jump to

Keyboard shortcuts

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