redis

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Service = dependency.Service{

	ConfigFunc: func(set dependency.FlagSet) {
		set.String(
			"redis-network",
			"tcp",
			"Network type to connect to redis with (unix/tcp)",
		)
		set.String(
			"redis-host",
			"localhost",
			"The host to connect to redis on",
		)
		set.Int(
			"redis-port",
			6379,
			"The port to connect to redis on",
		)
		set.String(
			"redis-password",
			"",
			"The password to connect to redis with",
		)
		set.Int(
			"redis-db",
			0,
			"The database to use on the redis connection",
		)
		set.Int(
			"redis-max-retries",
			0,
			"Maximum number of times to retry connecting to redis",
		)
		set.Duration(
			"redis-min-retry-backoff",
			8*time.Millisecond,
			"The minimum backoff time from a retry",
		)
		set.Duration(
			"redis-max-retry-backoff",
			512*time.Millisecond,
			"The maximum backoff time from a retry",
		)
		set.Duration(
			"redis-dial-timeout",
			5*time.Second,
			"The time to wait for a connection",
		)
		set.Duration(
			"redis-read-timeout",
			3*time.Second,
			"The time to wait for a read",
		)
		set.Duration(
			"redis-write-timeout",
			3*time.Second,
			"The time to wait on write",
		)
		set.Int(
			"redis-pool-size",
			10*runtime.NumCPU(),
			"Size of the connection pool",
		)
		set.Int(
			"redis-min-idle-conns",
			0,
			"The minimum number of idle connections",
		)
		set.Duration(
			"redis-max-conn-age",
			0,
			"The max age of a redis pool connection",
		)
		set.Duration(
			"redis-pool-timeout",
			4*time.Second,
			"Amount of time client waits for connection if all connections are busy before returning an error.",
		)
		set.Duration(
			"redis-idle-check-frequency",
			time.Minute,
			"The frequency that connections are checked to be dropped",
		)
	},
	Dependencies: fx.Provide(
		NewOptions,
		NewClientConstructor,
	),
	Constructor: New,
}

Service is the service to be used by the framework.Builder

Functions

func NewOptions

func NewOptions(config dependency.ConfigGetter) *redis.Options

NewOptions creates a new *redis.Options struct from configuration

Types

type ClientConstructor

type ClientConstructor func() Cmdable

NewClientConstructor is a type that can create an instance of a redis.Cmdable

func NewClientConstructor

func NewClientConstructor(options *redis.Options) ClientConstructor

NewClientConstructor is a type that can create a new instance of a ClientConstructor from a *redis.Options

type Cmdable

type Cmdable interface {
	redis.Cmdable
	WithContext(ctx context.Context) *redis.Client
}

Cmdable is an interface to abstract redis

func New

func New(constructor ClientConstructor, options *redis.Options, checker healthcheck.Handler) Cmdable

New creates a new instance of a *redis.Client

Jump to

Keyboard shortcuts

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