Documentation
¶
Index ¶
- type FakeClient
- func (fc *FakeClient) Close() error
- func (fc *FakeClient) RedisBGSave(ctx context.Context) error
- func (fc *FakeClient) RedisConfigGet(ctx context.Context, parameter string) ([]any, error)
- func (fc *FakeClient) RedisConfigSet(ctx context.Context, parameter, value string) error
- func (fc *FakeClient) RedisDebugSleep(ctx context.Context, duration time.Duration) error
- func (fc *FakeClient) RedisDo(ctx context.Context, args ...any) (any, error)
- func (fc *FakeClient) RedisInfo(ctx context.Context, section string) (string, error)
- func (fc *FakeClient) RedisLastSave(ctx context.Context) (int64, error)
- func (fc *FakeClient) RedisRole(ctx context.Context) (any, error)
- func (fc *FakeClient) RedisSet(ctx context.Context, key string, value any) error
- func (fc *FakeClient) RedisSlaveOf(ctx context.Context, host, port string) error
- func (fc *FakeClient) SentinelDo(ctx context.Context, args ...any) (any, error)
- func (fc *FakeClient) SentinelGetMasterAddrByName(ctx context.Context, shard string) ([]string, error)
- func (fc *FakeClient) SentinelInfoCache(ctx context.Context) (any, error)
- func (fc *FakeClient) SentinelMaster(ctx context.Context, shard string) (*SentinelMasterCmdResult, error)
- func (fc *FakeClient) SentinelMasters(ctx context.Context) ([]any, error)
- func (fc *FakeClient) SentinelMonitor(ctx context.Context, name, host string, port string, quorum int) error
- func (fc *FakeClient) SentinelPSubscribe(ctx context.Context, events ...string) (<-chan *redis.Message, func() error)
- func (fc *FakeClient) SentinelPing(ctx context.Context) error
- func (fc *FakeClient) SentinelSet(ctx context.Context, shard, parameter, value string) error
- func (fc *FakeClient) SentinelSlaves(ctx context.Context, shard string) ([]any, error)
- type FakeResponse
- type GoRedisClient
- func (c *GoRedisClient) Close() error
- func (c *GoRedisClient) CloseRedis() error
- func (c *GoRedisClient) CloseSentinel() error
- func (c *GoRedisClient) RedisBGSave(ctx context.Context) error
- func (c *GoRedisClient) RedisConfigGet(ctx context.Context, parameter string) ([]any, error)
- func (c *GoRedisClient) RedisConfigSet(ctx context.Context, parameter, value string) error
- func (c *GoRedisClient) RedisDebugSleep(ctx context.Context, duration time.Duration) error
- func (c *GoRedisClient) RedisDo(ctx context.Context, args ...any) (any, error)
- func (c *GoRedisClient) RedisInfo(ctx context.Context, section string) (string, error)
- func (c *GoRedisClient) RedisLastSave(ctx context.Context) (int64, error)
- func (c *GoRedisClient) RedisRole(ctx context.Context) (any, error)
- func (c *GoRedisClient) RedisSet(ctx context.Context, key string, value any) error
- func (c *GoRedisClient) RedisSlaveOf(ctx context.Context, host, port string) error
- func (c *GoRedisClient) SentinelDo(ctx context.Context, args ...any) (any, error)
- func (c *GoRedisClient) SentinelGetMasterAddrByName(ctx context.Context, shard string) ([]string, error)
- func (c *GoRedisClient) SentinelInfoCache(ctx context.Context) (any, error)
- func (c *GoRedisClient) SentinelMaster(ctx context.Context, shard string) (*SentinelMasterCmdResult, error)
- func (c *GoRedisClient) SentinelMasters(ctx context.Context) ([]any, error)
- func (c *GoRedisClient) SentinelMonitor(ctx context.Context, name, host string, port string, quorum int) error
- func (c *GoRedisClient) SentinelPSubscribe(ctx context.Context, events ...string) (<-chan *redis.Message, func() error)
- func (c *GoRedisClient) SentinelPing(ctx context.Context) error
- func (c *GoRedisClient) SentinelSet(ctx context.Context, shard, parameter, value string) error
- func (c *GoRedisClient) SentinelSlaves(ctx context.Context, shard string) ([]any, error)
- type RedisServerInfoCache
- type Role
- type SentinelInfoCache
- type SentinelMasterCmdResult
- type SentinelSlaveCmdResult
- type TestableInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FakeClient ¶
type FakeClient struct {
Responses []FakeResponse
}
func (*FakeClient) Close ¶
func (fc *FakeClient) Close() error
func (*FakeClient) RedisBGSave ¶
func (fc *FakeClient) RedisBGSave(ctx context.Context) error
func (*FakeClient) RedisConfigGet ¶
func (*FakeClient) RedisConfigSet ¶
func (fc *FakeClient) RedisConfigSet(ctx context.Context, parameter, value string) error
func (*FakeClient) RedisDebugSleep ¶
WARNING: this command blocks for the duration
func (*FakeClient) RedisLastSave ¶
func (fc *FakeClient) RedisLastSave(ctx context.Context) (int64, error)
func (*FakeClient) RedisSlaveOf ¶
func (fc *FakeClient) RedisSlaveOf(ctx context.Context, host, port string) error
func (*FakeClient) SentinelDo ¶
func (*FakeClient) SentinelGetMasterAddrByName ¶
func (*FakeClient) SentinelInfoCache ¶
func (fc *FakeClient) SentinelInfoCache(ctx context.Context) (any, error)
func (*FakeClient) SentinelMaster ¶
func (fc *FakeClient) SentinelMaster(ctx context.Context, shard string) (*SentinelMasterCmdResult, error)
func (*FakeClient) SentinelMasters ¶
func (fc *FakeClient) SentinelMasters(ctx context.Context) ([]any, error)
func (*FakeClient) SentinelMonitor ¶
func (*FakeClient) SentinelPSubscribe ¶
func (fc *FakeClient) SentinelPSubscribe(ctx context.Context, events ...string) (<-chan *redis.Message, func() error)
func (*FakeClient) SentinelPing ¶
func (fc *FakeClient) SentinelPing(ctx context.Context) error
func (*FakeClient) SentinelSet ¶
func (fc *FakeClient) SentinelSet(ctx context.Context, shard, parameter, value string) error
func (*FakeClient) SentinelSlaves ¶
type FakeResponse ¶
func NewPredefinedRedisFakeResponse ¶
func NewPredefinedRedisFakeResponse(dictionary string, err error) FakeResponse
Some predefined responses used in many tests
type GoRedisClient ¶
type GoRedisClient struct {
// contains filtered or unexported fields
}
func MustNewFromConnectionString ¶
func MustNewFromConnectionString(connectionString string) *GoRedisClient
func NewFromConnectionString ¶
func NewFromConnectionString(connectionString string) (*GoRedisClient, error)
func NewFromOptions ¶
func NewFromOptions(opt *redis.Options) *GoRedisClient
func (*GoRedisClient) Close ¶
func (c *GoRedisClient) Close() error
func (*GoRedisClient) CloseRedis ¶
func (c *GoRedisClient) CloseRedis() error
func (*GoRedisClient) CloseSentinel ¶
func (c *GoRedisClient) CloseSentinel() error
func (*GoRedisClient) RedisBGSave ¶
func (c *GoRedisClient) RedisBGSave(ctx context.Context) error
func (*GoRedisClient) RedisConfigGet ¶
func (*GoRedisClient) RedisConfigSet ¶
func (c *GoRedisClient) RedisConfigSet(ctx context.Context, parameter, value string) error
func (*GoRedisClient) RedisDebugSleep ¶
WARNING: this command blocks for the duration
func (*GoRedisClient) RedisLastSave ¶
func (c *GoRedisClient) RedisLastSave(ctx context.Context) (int64, error)
func (*GoRedisClient) RedisRole ¶
func (c *GoRedisClient) RedisRole(ctx context.Context) (any, error)
func (*GoRedisClient) RedisSlaveOf ¶
func (c *GoRedisClient) RedisSlaveOf(ctx context.Context, host, port string) error
func (*GoRedisClient) SentinelDo ¶
func (*GoRedisClient) SentinelGetMasterAddrByName ¶
func (*GoRedisClient) SentinelInfoCache ¶
func (c *GoRedisClient) SentinelInfoCache(ctx context.Context) (any, error)
func (*GoRedisClient) SentinelMaster ¶
func (c *GoRedisClient) SentinelMaster(ctx context.Context, shard string) (*SentinelMasterCmdResult, error)
func (*GoRedisClient) SentinelMasters ¶
func (c *GoRedisClient) SentinelMasters(ctx context.Context) ([]any, error)
func (*GoRedisClient) SentinelMonitor ¶
func (*GoRedisClient) SentinelPSubscribe ¶
func (c *GoRedisClient) SentinelPSubscribe(ctx context.Context, events ...string) (<-chan *redis.Message, func() error)
func (*GoRedisClient) SentinelPing ¶
func (c *GoRedisClient) SentinelPing(ctx context.Context) error
func (*GoRedisClient) SentinelSet ¶
func (c *GoRedisClient) SentinelSet(ctx context.Context, shard, parameter, value string) error
func (*GoRedisClient) SentinelSlaves ¶
type RedisServerInfoCache ¶
type Role ¶
type Role string
Role represents the role of a redis server within a shard
const ( // Master is the master role in a shard. Under normal circumstances, only // a server in the shard can be master at a given time Master Role = "master" // Slave are servers within the shard that replicate data from the master // for data high availability purposes Slave Role = "slave" // Unknown represents a state in which the role of the server is still unknown Unknown Role = "unknown" )
type SentinelInfoCache ¶
type SentinelInfoCache map[string]map[string]RedisServerInfoCache
type SentinelMasterCmdResult ¶
type SentinelMasterCmdResult struct {
Name string `redis:"name"`
IP string `redis:"ip"`
Port int `redis:"port"`
RunID string `redis:"runid"`
Flags string `redis:"flags"`
LinkPendingCommands int `redis:"link-pending-commands"`
LinkRefcount int `redis:"link-refcount"`
LastPingSent int `redis:"last-ping-sent"`
LastOkPingReply int `redis:"last-ok-ping-reply"`
LastPingReply int `redis:"last-ping-reply"`
DownAfterMilliseconds int `redis:"down-after-milliseconds"`
InfoRefresh int `redis:"info-refresh"`
RoleReported string `redis:"role-reported"`
RoleReportedTime int `redis:"role-reported-time"`
ConfigEpoch int `redis:"config-epoch"`
NumSlaves int `redis:"num-slaves"`
NumOtherSentinels int `redis:"num-other-sentinels"`
Quorum int `redis:"quorum"`
FailoverTimeout int `redis:"failover-timeout"`
ParallelSyncs int `redis:"parallel-syncs"`
}
SentinelMasterCmdResult represents the output of the "sentinel master" command
type SentinelSlaveCmdResult ¶
type SentinelSlaveCmdResult struct {
Name string `redis:"name"`
IP string `redis:"ip"`
Port int `redis:"port"`
RunID string `redis:"runid"`
Flags string `redis:"flags"`
LinkPendingCommands int `redis:"link-pending-commands"`
LinkRefcount int `redis:"link-refcount"`
LastPingSent int `redis:"last-ping-sent"`
LastOkPingReply int `redis:"last-ok-ping-reply"`
LastPingReply int `redis:"last-ping-reply"`
DownAfterMilliseconds int `redis:"down-after-milliseconds"`
InfoRefresh int `redis:"info-refresh"`
RoleReported string `redis:"role-reported"`
RoleReportedTime int `redis:"role-reported-time"`
MasterLinkDownTime int `redis:"master-link-down-time"`
MasterLinkStatus string `redis:"master-link-status"`
MasterHost string `redis:"master-host"`
MasterPort int `redis:"master-port"`
SlavePriority int `redis:"slave-priority"`
SlaveReplOffset int `redis:"slave-repl-offset"`
}
SentinelSlaveCmdResult represents the output of the "sentinel slave" command
type TestableInterface ¶
type TestableInterface interface {
SentinelMaster(context.Context, string) (*SentinelMasterCmdResult, error)
SentinelMasters(context.Context) ([]any, error)
SentinelGetMasterAddrByName(ctx context.Context, shard string) ([]string, error)
SentinelSlaves(context.Context, string) ([]any, error)
SentinelMonitor(context.Context, string, string, string, int) error
SentinelSet(context.Context, string, string, string) error
SentinelPSubscribe(context.Context, ...string) (<-chan *redis.Message, func() error)
SentinelInfoCache(context.Context) (any, error)
SentinelDo(context.Context, ...any) (any, error)
SentinelPing(ctx context.Context) error
RedisRole(context.Context) (any, error)
RedisConfigGet(context.Context, string) ([]any, error)
RedisConfigSet(context.Context, string, string) error
RedisSlaveOf(context.Context, string, string) error
RedisDebugSleep(context.Context, time.Duration) error
RedisDo(context.Context, ...any) (any, error)
RedisBGSave(context.Context) error
RedisLastSave(context.Context) (int64, error)
RedisSet(context.Context, string, any) error
RedisInfo(ctx context.Context, section string) (string, error)
Close() error
}
TestableInterface is an interface that both the go-redis and the fake client implement. It's not intended to support client implementations other than go-redis, it just exists to be able to inject redis server responses through the use of the Fake client, for testing purposes.
func NewFakeClient ¶
func NewFakeClient(responses ...FakeResponse) TestableInterface