Documentation ¶
Index ¶
- Constants
- func IsConnectionError(err error) bool
- func NewFailoverOptions(sURL string, db int, logger zerolog.Logger, reconnectCount int, ...) (*redis.FailoverOptions, error)
- func NewOptions(surl string, db int, logger zerolog.Logger, reconnectCount int, ...) (*redis.Options, error)
- func NewSession(ctx context.Context, db int, logger zerolog.Logger, reconnectCount int, ...) (*redis.Client, error)
- type Lock
- type LockClient
- type Store
Constants ¶
const ( PeriodicalLockKey = "pbehavior-periodical-lock-key" RecomputeLockKey = "pbehavior-recompute-lock-key" RecomputeLockDuration = 10 * time.Second DelayedScenarioKey = "delayed-scenario" ScenarioExecutionKey = "scenario-execution" )
const ( CacheAlarm = iota CacheEntity CacheService LockStorage QueueStorage CacheQueue AxePeriodicalLockStorage RuleTotalEntitiesStorage AlarmGroupStorage CorrelationLockStorage EngineRunInfo PBehaviorLockStorage ActionScenarioStorage EntityServiceStorage EngineLockStorage )
Cache<Type> gives you constants to use for different caches.
const (
EnvURL = "CPS_REDIS_URL"
)
Env vars for redis session
const PbehaviorKey = "pbehaviors"
Variables ¶
This section is empty.
Functions ¶
func IsConnectionError ¶
func NewFailoverOptions ¶
func NewFailoverOptions(sURL string, db int, logger zerolog.Logger, reconnectCount int, minReconnectTimeout time.Duration) (*redis.FailoverOptions, error)
NewFailoverOptions handles redis.FailoverOptions creation based on the provided url, which must be on the following shape:
redis-sentinel://[password@]host1[:port1][,host2[:port2]][,hostN[:portN]][/database][?
[timeout=timeout[d|h|m|s|ms|us|ns]][&sentinelMasterId=sentinelMasterId]]
As well supported password parameter same as in NewOptions():
redis://[nouser:password@]host:port/int
With this form "nouser" is ignored, and "password" extracted only.
func NewOptions ¶
func NewOptions(surl string, db int, logger zerolog.Logger, reconnectCount int, minReconnectTimeout time.Duration) (*redis.Options, error)
NewOptions handles redis.Options creation based on the surl, which must be on the following shape:
redis://[nouser:password@]host:port/int int must be un number indicating the database
If you have a password for the database, no user is required. But it is required to not leave the user empty to avoid url parsing error.
Types ¶
type LockClient ¶
type LockClient interface {
Obtain(ctx context.Context, key string, ttl time.Duration, opt *redislock.Options) (Lock, error)
}
func NewLockClient ¶
func NewLockClient(redisClient redislock.RedisClient) LockClient
type Store ¶
type Store interface { // Save prepares value and saves the result to redis. Save(ctx context.Context, v interface{}) error // Restore gets data from redis and stores the result // in the value pointed to by v. Restore(ctx context.Context, v interface{}) (bool, error) }
Store interface is used to implement baseStore any variable to redis. Basic implementation marshals data to json before stores it to cache.