Documentation ¶
Index ¶
- Variables
- func InitializeContext(ctx context.Context) context.Context
- type ClientFunctions
- type ClientService
- func (c ClientService) Do(ctx context.Context, client *redis.Client, op string, db int) error
- func (c ClientService) Exists(ctx context.Context, client *redis.Client, keys ...string) (int64, error)
- func (c ClientService) Get(ctx context.Context, client *redis.Client, key string) (string, error)
- func (c ClientService) HGetAll(ctx context.Context, client *redis.Client, key string) (map[string]string, error)
- func (c ClientService) HSet(ctx context.Context, client *redis.Client, key string, values ...interface{}) error
- func (c ClientService) PExpire(ctx context.Context, client *redis.Client, key string, ...) error
- func (c ClientService) Ping(ctx context.Context, client *redis.Client) error
- func (c ClientService) PubSubChannel(pubSub *redis.PubSub) <-chan *redis.Message
- func (c ClientService) PubSubClose(pubSub *redis.PubSub) error
- func (c ClientService) PubSubReceive(ctx context.Context, pubSub *redis.PubSub) (interface{}, error)
- func (c ClientService) Publish(ctx context.Context, client *redis.Client, channel string, message interface{}) error
- func (c ClientService) Set(ctx context.Context, client *redis.Client, key string, value interface{}, ...) error
- func (c ClientService) Subscribe(ctx context.Context, client *redis.Client, channels ...string) *redis.PubSub
- type ClientServiceFuncMock
- func (c ClientServiceFuncMock) Do(ctx context.Context, client *redis.Client, op string, db int) error
- func (c ClientServiceFuncMock) Exists(ctx context.Context, client *redis.Client, keys ...string) (int64, error)
- func (c ClientServiceFuncMock) Get(ctx context.Context, client *redis.Client, key string) (string, error)
- func (c ClientServiceFuncMock) HGetAll(ctx context.Context, client *redis.Client, key string) (map[string]string, error)
- func (c ClientServiceFuncMock) HSet(ctx context.Context, client *redis.Client, key string, values ...interface{}) error
- func (c ClientServiceFuncMock) PExpire(ctx context.Context, client *redis.Client, key string, ...) error
- func (c ClientServiceFuncMock) Ping(ctx context.Context, client *redis.Client) error
- func (c ClientServiceFuncMock) PubSubChannel(pubSub *redis.PubSub) <-chan *redis.Message
- func (c ClientServiceFuncMock) PubSubClose(pubSub *redis.PubSub) error
- func (c ClientServiceFuncMock) PubSubReceive(ctx context.Context, pubSub *redis.PubSub) (interface{}, error)
- func (c ClientServiceFuncMock) Publish(ctx context.Context, client *redis.Client, channel string, message interface{}) error
- func (c ClientServiceFuncMock) Set(ctx context.Context, client *redis.Client, key string, value interface{}, ...) error
- func (c ClientServiceFuncMock) Subscribe(ctx context.Context, client *redis.Client, channels ...string) *redis.PubSub
- type ContextKey
- type Logger
- func (l Logger) LogExistsKey(key string, exits int, corr string)
- func (l Logger) LogGetKey(key, value, 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 ¶
Functions ¶
Types ¶
type ClientFunctions ¶ added in v0.16.0
type ClientFunctions interface { Ping(ctx context.Context, client *redis.Client) error Do(ctx context.Context, client *redis.Client, op string, db int) error Set( ctx context.Context, client *redis.Client, key string, value interface{}, expiration time.Duration, ) error HSet( ctx context.Context, client *redis.Client, key string, values ...interface{}, ) error PExpire( ctx context.Context, client *redis.Client, key string, expiration time.Duration, ) error Exists( ctx context.Context, client *redis.Client, keys ...string, ) (int64, error) Get( ctx context.Context, client *redis.Client, key string, ) (string, error) HGetAll( ctx context.Context, client *redis.Client, key string, ) (map[string]string, error) Subscribe( ctx context.Context, client *redis.Client, channels ...string, ) *redis.PubSub PubSubReceive( ctx context.Context, pubSub *redis.PubSub, ) (interface{}, error) PubSubChannel( pubSub *redis.PubSub, ) <-chan *redis.Message Publish(ctx context.Context, client *redis.Client, channel string, message interface{}, ) error PubSubClose(pubSub *redis.PubSub) error }
type ClientService ¶ added in v0.16.0
type ClientService struct{}
func NewRedisClientService ¶ added in v0.16.0
func NewRedisClientService() *ClientService
func (ClientService) HSet ¶ added in v0.16.0
func (c ClientService) HSet( ctx context.Context, client *redis.Client, key string, values ...interface{}, ) error
func (ClientService) Ping ¶ added in v0.16.0
func (c ClientService) Ping(ctx context.Context, client *redis.Client) error
func (ClientService) PubSubChannel ¶ added in v0.16.0
func (c ClientService) PubSubChannel( pubSub *redis.PubSub, ) <-chan *redis.Message
func (ClientService) PubSubClose ¶ added in v0.16.0
func (c ClientService) PubSubClose(pubSub *redis.PubSub) error
func (ClientService) PubSubReceive ¶ added in v0.16.0
func (c ClientService) PubSubReceive( ctx context.Context, pubSub *redis.PubSub, ) (interface{}, error)
func (ClientService) Publish ¶ added in v0.16.0
func (c ClientService) Publish(ctx context.Context, client *redis.Client, channel string, message interface{}, ) error
type ClientServiceFuncMock ¶ added in v0.16.0
type ClientServiceFuncMock struct{}
func (ClientServiceFuncMock) HSet ¶ added in v0.16.0
func (c ClientServiceFuncMock) HSet( ctx context.Context, client *redis.Client, key string, values ...interface{}, ) error
func (ClientServiceFuncMock) Ping ¶ added in v0.16.0
func (c ClientServiceFuncMock) Ping(ctx context.Context, client *redis.Client) error
func (ClientServiceFuncMock) PubSubChannel ¶ added in v0.16.0
func (c ClientServiceFuncMock) PubSubChannel( pubSub *redis.PubSub, ) <-chan *redis.Message
func (ClientServiceFuncMock) PubSubClose ¶ added in v0.16.0
func (c ClientServiceFuncMock) PubSubClose(pubSub *redis.PubSub) error
func (ClientServiceFuncMock) PubSubReceive ¶ added in v0.16.0
func (c ClientServiceFuncMock) PubSubReceive( ctx context.Context, pubSub *redis.PubSub, ) (interface{}, error)
func (ClientServiceFuncMock) Publish ¶ added in v0.16.0
func (c ClientServiceFuncMock) Publish(ctx context.Context, client *redis.Client, channel string, message interface{}, ) error
type ContextKey ¶
type ContextKey string
ContextKey defines a type to store the redis session in context.Context.
type Logger ¶
Logger logs in a configurable file.
func GetLogger ¶
func GetLogger() *Logger
GetLogger returns the logger for HTTP requests and responses. If the logger is not created yet, it creates a new instance of Logger.
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 RedisClientService ClientFunctions // 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 ¶
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 ¶
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.