redis

package
v0.0.0-...-f0e227c Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WrapCmdErr

func WrapCmdErr(cmd redis.Cmder) error

WrapCmdErr adds the command itself and the stack of the current goroutine to the command's error if any.

Types

type Client

type Client struct {
	*redis.Client

	Options *Options
	// contains filtered or unexported fields
}

Client is a wrapper around redis.Client with streaming and logging capabilities.

func NewClient

func NewClient(client *redis.Client, logger *logging.Logger, options *Options) *Client

NewClient returns a new Client wrapper for a pre-existing redis.Client.

func NewClientFromConfig

func NewClientFromConfig(c *Config, logger *logging.Logger) (*Client, error)

NewClientFromConfig returns a new Client from Config.

func (*Client) HMYield

func (c *Client) HMYield(ctx context.Context, key string, fields ...string) (<-chan HPair, <-chan error)

HMYield yields HPair field-value pairs for the specified fields in the hash stored at key.

func (*Client) HYield

func (c *Client) HYield(ctx context.Context, key string) (<-chan HPair, <-chan error)

HYield yields HPair field-value pairs for all fields in the hash stored at key.

func (*Client) XReadUntilResult

func (c *Client) XReadUntilResult(ctx context.Context, a *redis.XReadArgs) ([]redis.XStream, error)

XReadUntilResult (repeatedly) calls XREAD with the specified arguments until a result is returned. Each call blocks at most for the duration specified in Options.BlockTimeout until data is available before it times out and the next call is made. This also means that an already set block timeout is overridden.

type Config

type Config struct {
	Host       string     `yaml:"host"`
	Port       int        `yaml:"port"`
	Database   int        `yaml:"database" default:"0"`
	Password   string     `yaml:"password"`
	TlsOptions config.TLS `yaml:",inline"`
	Options    Options    `yaml:"options"`
}

Config defines Config client configuration.

func (*Config) Validate

func (r *Config) Validate() error

Validate checks constraints in the supplied Config configuration and returns an error if they are violated.

type HPair

type HPair struct {
	Field string
	Value string
}

HPair defines Redis hashes field-value pairs.

type Options

type Options struct {
	BlockTimeout        time.Duration `yaml:"block_timeout"         default:"1s"`
	HMGetCount          int           `yaml:"hmget_count"           default:"4096"`
	HScanCount          int           `yaml:"hscan_count"           default:"4096"`
	MaxHMGetConnections int           `yaml:"max_hmget_connections" default:"8"`
	MinPoolSize         int           `yaml:"min_pool_size"         default:"32"`
	Timeout             time.Duration `yaml:"timeout"               default:"30s"`
	XReadCount          int           `yaml:"xread_count"           default:"4096"`
}

Options define user configurable Redis options.

func (*Options) Validate

func (o *Options) Validate() error

Validate checks constraints in the supplied Redis options and returns an error if they are violated.

type Streams

type Streams map[string]string

Streams represents a Redis stream key to ID mapping.

func (Streams) Option

func (s Streams) Option() []string

Option returns the Redis stream key to ID mapping as a slice of stream keys followed by their IDs that is compatible for the Redis STREAMS option.

Jump to

Keyboard shortcuts

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