redis

package
v0.0.0-...-9b5cd94 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyDelimiter = "$$"

	RunInfoKey = "engine-run-info"

	PbehaviorPeriodicalLockKey      = "pbehavior-periodical-lock-key"
	PbehaviorCleanPeriodicalLockKey = "pbehavior-clean-periodical-lock-key"
	RecomputeLockKey                = "pbehavior-recompute-lock-key"
	RecomputeLockDuration           = 10 * time.Second

	ActionPeriodicalLockKey    = "action-periodical-lock-key"
	ActionDelayedScenarioKey   = "action-delayed-scenario"
	ActionScenarioExecutionKey = "action-scenario-execution"

	AxePeriodicalLockKey                  = "axe-periodical-lock-key"
	AxeResolvedArchiverPeriodicalLockKey  = "axe-resolved-archiver-periodical-lock-key"
	AxeInternalTagsPeriodicalLockKey      = "axe-internal-tags-periodical-lock-key"
	AxeEntityServiceStateLockKey          = "axe-entity-service-state-lock-key"
	AxeIdleSincePeriodicalLockKey         = "axe-idle-since-periodical-lock-key"
	AxeNotAckedMetricsPeriodicalLockKey   = "axe-not-acked-metrics-periodical-lock-key"
	AxeSliMetricsPeriodicalLockKey        = "axe-sli-metrics-periodical-lock-key"
	AxeCleanExternalTagsPeriodicalLockKey = "axe-clean-external-tags-periodical-lock-key"

	FifoDeleteOutdatedRatesLockKey = "fifo-delete-outdated-rates-lock-key"

	ChePeriodicalLockKey                      = "che-periodical-lock-key"
	CheSoftDeletePeriodicalLockKey            = "che-soft-delete-periodical-lock-key"
	CheEntityInfosDictionaryPeriodicalLockKey = "che-entity-infos-dictionary-periodical-lock-key"
	CheEventFiltersIntervalsPeriodicalLockKey = "che-event-filters-intervals-periodical-lock-key"

	RemediationPeriodicalLockKey        = "remediation-periodical-lock-key"
	RemediationStatsPeriodicalLockKey   = "remediation-stats-periodical-lock-key"
	RemediationPostponedJobTasksLockKey = "remediation-postponed-job-tasks-lock-key"

	PbehaviorSpanKey              = "pbehavior-span"
	PbehaviorTypesKey             = "pbehavior-types"
	PbehaviorDefaultActiveTypeKey = "pbehavior-default-active-type"
	PbehaviorComputedKey          = "pbehavior-computed-"

	DynamicInfosDictionaryPeriodicalLockKey = "dynamic-infos-dictionary-periodical-lock-key"

	ApiCleanEntitiesLockKey      = "api-clean-entities-lock-key"
	ApiUserActivityMetricLockKey = "api-user-activity-metric"
	ApiCacheRequestKey           = "api-cache-request"

	CorrelationInactiveDelayPeriodicalLockKey = "correlation-inactive-delay-periodical-lock-key"
)
View Source
const (
	CacheAlarm = iota
	CacheEntity
	CacheService

	LockStorage
	QueueStorage
	ApiCacheQueue
	AxePeriodicalLockStorage
	RuleTotalEntitiesStorage
	AlarmGroupStorage
	CorrelationLockStorage
	EngineRunInfo
	PBehaviorLockStorage
	ActionScenarioStorage
	EntityServiceStorage
	FIFOMessageStatisticsStorage
	// EngineLockStorage is used for all redis locks. It should be used by all engines.
	EngineLockStorage
)

Cache<Type> gives you constants to use for different caches.

View Source
const (
	EnvURL = "CPS_REDIS_URL"
)

Env vars for redis session

Variables

This section is empty.

Functions

func IsConnectionError

func IsConnectionError(err error) bool

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.

func NewSession

func NewSession(ctx context.Context, db int, logger zerolog.Logger, reconnectCount int, minReconnectTimeout time.Duration) (*redis.Client, error)

NewSession creates a new connection to a Redis database. Configuration is base on EnvCpsRedisUrl.

Types

type Lock

type Lock interface {
	Key() string
	Token() string
	TTL(ctx context.Context) (time.Duration, error)
	Refresh(ctx context.Context, ttl time.Duration, opt *redislock.Options) error
	Release(ctx context.Context) error
}

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

Jump to

Keyboard shortcuts

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