Documentation
¶
Index ¶
- Constants
- Variables
- func ClusterEnable() bool
- func DatabaseNumber() int
- func IsLockFailure(err error) bool
- func IsNil(err error) bool
- func Lock(ctx context.Context, key string, expiration time.Duration) (bool, error)
- func Ping(ctx context.Context) error
- func Primary() redis.UniversalClient
- func PrimaryEndpoint() string
- func ReadOnly(ctx context.Context, f func(ctx context.Context, c redis.Cmdable) error, ...) (err error)
- func Reader() redis.Cmdable
- func ReaderEndpoint() string
- func Refresh(ctx context.Context, b ...Builder) error
- func ServerName() string
- func Setup(ctx context.Context, b Builder) error
- func TlsEnable() bool
- func Universal(ctx context.Context, f func(ctx context.Context, c redis.Cmdable) error, ...) (err error)
- func WaitForActivation(ctx context.Context, waitMax ...int) error
- func WithLock(ctx context.Context, key string, f func() error, tryMax ...int) error
- type Builder
- type DefaultBuilder
- type Env
- type EnvBuilder
- type LockFailure
- type MockBuilder
- type PrimaryClient
- type ReaderClient
Constants ¶
View Source
const ( DefaultHost = "localhost:6379" Nil = redis.Nil )
View Source
const Locked = "1"
Variables ¶
View Source
var LockTime = 15 * time.Second
Functions ¶
func ClusterEnable ¶
func ClusterEnable() bool
func DatabaseNumber ¶
func DatabaseNumber() int
func IsLockFailure ¶ added in v0.0.7
func PrimaryEndpoint ¶
func PrimaryEndpoint() string
func ReaderEndpoint ¶
func ReaderEndpoint() string
func ServerName ¶ added in v0.0.4
func ServerName() string
Types ¶
type Builder ¶
type Builder interface {
Build(ctx context.Context, db ...int) (*PrimaryClient, *ReaderClient, error)
}
type DefaultBuilder ¶
type DefaultBuilder struct { ClusterEnable bool PrimaryHost string ReaderHost string TlsConfig *tls.Config }
func (*DefaultBuilder) Build ¶
func (b *DefaultBuilder) Build(ctx context.Context, db ...int) (primary *PrimaryClient, reader *ReaderClient, err error)
type Env ¶
type Env struct { RedisPrimaryEndpoint string `envar:"REDIS_PRIMARY_ENDPOINT;default=localhost:6379"` RedisReaderEndpoint string `envar:"REDIS_READER_ENDPOINT"` RedisClusterEnable bool `envar:"REDIS_CLUSTER_ENABLE"` RedisDatabaseNumber int `envar:"REDIS_DATABASE_NUMBER;default=0"` TlsEnable bool `envar:"REDIS_TLS_ENABLE"` RedisServerName string `envar:"REDIS_SERVER_NAME"` }
type EnvBuilder ¶
type EnvBuilder struct{}
func (*EnvBuilder) Build ¶
func (b *EnvBuilder) Build(ctx context.Context, db ...int) (primary *PrimaryClient, reader *ReaderClient, err error)
type LockFailure ¶ added in v0.0.7
type LockFailure struct{}
func (*LockFailure) Error ¶ added in v0.0.7
func (err *LockFailure) Error() string
type MockBuilder ¶
type MockBuilder struct {
// contains filtered or unexported fields
}
func (*MockBuilder) Build ¶
func (b *MockBuilder) Build(ctx context.Context, db ...int) (primary *PrimaryClient, reader *ReaderClient, err error)
func (*MockBuilder) Mock ¶
func (b *MockBuilder) Mock() redismock.ClientMock
type PrimaryClient ¶
type PrimaryClient struct { Client redis.UniversalClient Db int }
type ReaderClient ¶
type ReaderClient struct { Client redis.Cmdable Db int }
Click to show internal directories.
Click to hide internal directories.