redis

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2022 License: Apache-2.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 redis 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 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

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

NewLogger creates an instance of the logger. It configures the file path where the HTTP request and response are written.

func (Logger) LogExistsKey

func (l Logger) LogExistsKey(key string, exits int, corr string)

LogExistsKey logs a redis EXISTS command.

func (Logger) LogGetKey

func (l Logger) LogGetKey(key, value string, corr string)

LogGetKey logs a redis GET command.

func (Logger) LogHGetKey

func (l Logger) LogHGetKey(key string, value interface{}, corr string)

LogHGetKey logs a redis HGET command.

func (Logger) LogHSetKey

func (l Logger) LogHSetKey(key string, value interface{}, corr string)

LogHSetKey logs a redis HSET command.

func (Logger) LogPublishedMessage

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

LogPublishedMessage logs a redis message published to a topic.

func (Logger) LogReceivedMessage

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

LogReceivedMessage logs a redis message received from a topic.

func (Logger) LogSetKey

func (l Logger) LogSetKey(key, value, corr string)

LogSetKey logs a redis SET command.

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

func GetSession(ctx context.Context) *Session

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

func (*Session) ConfigureClient

func (s *Session) ConfigureClient(ctx context.Context, options *redis.Options) error

ConfigureClient creates a redis client based on the configuration in options.

func (*Session) ConfigureTTL

func (s *Session) ConfigureTTL(ctx context.Context, ttl int)

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

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

PublishTextMessage publishes a text message in a redis topic.

func (*Session) SelectDatabase

func (s *Session) SelectDatabase(ctx context.Context, db int) error

SelectDatabase select redis database for current connection

func (*Session) SetHashValue

func (s *Session) SetHashValue(ctx context.Context, key string, value map[string]interface{}) error

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

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

SetJSONValue sets a redis key with a JSON document extracted from a table of properties.

func (*Session) SetTextValue

func (s *Session) SetTextValue(ctx context.Context, key, value string) error

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

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

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

func (*Session) UnsubscribeTopic

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

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

func (s *Session) ValidateNonExistantKey(ctx context.Context, key string) error

ValidateNonExistantKey checks if the redis key has not value.

func (*Session) ValidateTextValue

func (s *Session) ValidateTextValue(ctx context.Context, key, expectedValue string) error

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.

func (*Session) WaitForTextMessage

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

WaitForTextMessage waits up to timeout till 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