Documentation
¶
Index ¶
- func InitializeContext(ctx context.Context) context.Context
- type ContextKey
- type Logger
- func (l Logger) LogExistsKey(key string, exits int, corr string)
- func (l Logger) LogGetKey(key, value string, corr string)
- func (l Logger) LogHGetKey(key string, value interface{}, corr string)
- func (l Logger) LogHSetKey(key string, value interface{}, corr string)
- func (l Logger) LogPublishedMessage(msg, topic, corr string)
- func (l Logger) LogReceivedMessage(msg, topic, corr string)
- func (l Logger) LogSetKey(key, value, corr string)
- type Session
- func (s *Session) ConfigureClient(ctx context.Context, options *redis.Options) error
- func (s *Session) ConfigureTTL(ctx context.Context, ttl int)
- func (s *Session) PublishJSONMessage(ctx context.Context, topic string, props map[string]interface{}) error
- func (s *Session) PublishTextMessage(ctx context.Context, topic, message string) error
- func (s *Session) SelectDatabase(ctx context.Context, db int) error
- func (s *Session) SetHashValue(ctx context.Context, key string, value map[string]interface{}) error
- func (s *Session) SetJSONValue(ctx context.Context, key string, props map[string]interface{}) error
- func (s *Session) SetTextValue(ctx context.Context, key, value string) error
- func (s *Session) SubscribeTopic(ctx context.Context, topic string) error
- func (s *Session) UnsubscribeTopic(ctx context.Context, topic string) error
- func (s *Session) ValidateHashValue(ctx context.Context, key string, props map[string]interface{}) error
- func (s *Session) ValidateJSONValue(ctx context.Context, key string, props map[string]interface{}) error
- func (s *Session) ValidateNonExistantKey(ctx context.Context, key string) error
- func (s *Session) ValidateTextValue(ctx context.Context, key, expectedValue string) error
- func (s *Session) WaitForJSONMessageWithProperties(ctx context.Context, timeout time.Duration, props map[string]interface{}) error
- func (s *Session) WaitForTextMessage(ctx context.Context, timeout time.Duration, expectedMsg string) error
- type Steps
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ContextKey ¶
type ContextKey string
ContextKey defines a type to store the redis 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 redis messages in publish/subscribe. If the logger is not created yet, it creates a new instance of Logger.
func NewLogger ¶
NewLogger creates an instance of the logger. It configures the file path where the HTTP request and response are written.
func (Logger) LogExistsKey ¶
LogExistsKey logs a redis EXISTS command.
func (Logger) LogHGetKey ¶
LogHGetKey logs a redis HGET command.
func (Logger) LogHSetKey ¶
LogHSetKey logs a redis HSET command.
func (Logger) LogPublishedMessage ¶
LogPublishedMessage logs a redis message published to a topic.
func (Logger) LogReceivedMessage ¶
LogReceivedMessage logs a redis message received from a topic.
type Session ¶
type Session struct {
Client *redis.Client
// Messages received from the publish/subscribe channel
Messages []string
// Correlator is used to correlate the messages for a specific session
Correlator string
// Time to live (in milliseconds). If 0, there is no TTL configured for new records
TTL int
// contains filtered or unexported fields
}
Session contains the information of a redis session.
func GetSession ¶
GetSession returns the redis session stored in context. Note that the context should be previously initialized with InitializeContext function.
func (*Session) ConfigureClient ¶
ConfigureClient creates a redis client based on the configuration in options.
func (*Session) ConfigureTTL ¶
ConfigureTTL saves TTL (in milliseconds) to apply when setting a value in redis.
func (*Session) PublishJSONMessage ¶
func (s *Session) PublishJSONMessage(ctx context.Context, topic string, props map[string]interface{}) error
PublishJSONMessage publishes a JSON message in a redis topic.
func (*Session) PublishTextMessage ¶
PublishTextMessage publishes a text message in a redis topic.
func (*Session) SelectDatabase ¶
SelectDatabase select redis database for current connection
func (*Session) SetHashValue ¶
SetHashValue sets a redis key with a mapped value. It uses session TTL to establish an expiration time (no expiration if TTL is 0).
func (*Session) SetJSONValue ¶
SetJSONValue sets a redis key with a JSON document extracted from a table of properties.
func (*Session) SetTextValue ¶
SetTextValue sets a redis key with a text value. It uses session TTL to establish an expiration time (no expiration if TTL is 0).
func (*Session) SubscribeTopic ¶
SubscribeTopic subscribes to a redis topic to receive messages via a channel.
func (*Session) UnsubscribeTopic ¶
UnsubscribeTopic unsubscribes from a redis topic to stop receiving messages via a channel. The channel is closed. If this method is not invoked, then the goroutine created with SubscribeTopic is never closed and will permanently process messages from the topic until the program is finished.
func (*Session) ValidateHashValue ¶
func (s *Session) ValidateHashValue(ctx context.Context, key string, props map[string]interface{}) error
ValidateHashValue checks if the mapped value for a redis key equals the expected value. It uses session TTL to establish an expiration time (no expiration if TTL is 0).
func (*Session) ValidateJSONValue ¶
func (s *Session) ValidateJSONValue(ctx context.Context, key string, props map[string]interface{}) error
ValidateJSONValue checks if the JSON value for a redis key complies with the table of properties.
func (*Session) ValidateNonExistantKey ¶
ValidateNonExistantKey checks if the redis key has not value.
func (*Session) ValidateTextValue ¶
ValidateTextValue checks if the text value for a redis key equals the expected value. It uses session TTL to establish an expiration time (no expiration if TTL is 0).
func (*Session) WaitForJSONMessageWithProperties ¶
func (s *Session) WaitForJSONMessageWithProperties(ctx context.Context, timeout time.Duration, props map[string]interface{}) error
WaitForJSONMessageWithProperties waits 1 second and verifies if there is a message received in the topic with the requested properties.