redis

package
v0.44.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package redis handles our remote database layer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v0.44.0

type Config struct {
	Hostname           string
	Port               int
	Password           string
	Username           string
	TLSEnabled         bool
	InsecureSkipVerify bool
	DB                 int
	// ClusterAddresses is a list of cluster node addresses. When set, cluster mode is used.
	ClusterAddresses []string
}

Config holds configuration for Redis connections.

type RedisDB

type RedisDB struct {
	// contains filtered or unexported fields
}

RedisDB is a database using Redis 6+

func New

func New(hostname string, port int, password string, tlsEnabled bool, insecureSkipVerify bool, db int) (*RedisDB, error)

New creates a new RedisDB for client interactions with redis. Deprecated: Use NewWithConfig for new code.

func NewWithClient

func NewWithClient(client *redis.Client, _ string, _ string) (*RedisDB, error)

NewWithClient is used for testing.

func NewWithConfig added in v0.44.0

func NewWithConfig(cfg Config) (*RedisDB, error)

NewWithConfig creates a new RedisDB based on the provided configuration. It automatically selects the appropriate Redis client type: - If ClusterAddresses is set, uses Redis Cluster mode - Otherwise, uses single-node mode

func (*RedisDB) CheckCommandLock

func (r *RedisDB) CheckCommandLock(cmdName command.Name) (*command.Lock, error)

func (*RedisDB) Close added in v0.37.0

func (r *RedisDB) Close() error

func (*RedisDB) DeletePullStatus

func (r *RedisDB) DeletePullStatus(pull models.PullRequest) error

func (*RedisDB) GetLock

func (r *RedisDB) GetLock(project models.Project, workspace string) (*models.ProjectLock, error)

GetLock returns a pointer to the lock for that project and workspace. If there is no lock, it returns a nil pointer.

func (*RedisDB) GetPullStatus

func (r *RedisDB) GetPullStatus(pull models.PullRequest) (*models.PullStatus, error)

func (*RedisDB) List

func (r *RedisDB) List() ([]models.ProjectLock, error)

List lists all current locks.

func (*RedisDB) LockCommand

func (r *RedisDB) LockCommand(cmdName command.Name, lockTime time.Time) (*command.Lock, error)

func (*RedisDB) Ping added in v0.44.0

func (r *RedisDB) Ping() error

Ping checks the Redis connection health.

func (*RedisDB) TryLock

func (r *RedisDB) TryLock(newLock models.ProjectLock) (bool, models.ProjectLock, error)

TryLock attempts to create a new lock. If the lock is acquired, it will return true and the lock returned will be newLock. If the lock is not acquired, it will return false and the current lock that is preventing this lock from being acquired.

func (*RedisDB) Unlock

func (r *RedisDB) Unlock(project models.Project, workspace string) (*models.ProjectLock, error)

Unlock attempts to unlock the project and workspace. If there is no lock, then it will return a nil pointer. If there is a lock, then it will delete it, and then return a pointer to the deleted lock.

func (*RedisDB) UnlockByPull

func (r *RedisDB) UnlockByPull(repoFullName string, pullNum int) ([]models.ProjectLock, error)

UnlockByPull deletes all locks associated with that pull request and returns them.

func (*RedisDB) UnlockCommand

func (r *RedisDB) UnlockCommand(cmdName command.Name) error

func (*RedisDB) UpdateProjectStatus

func (r *RedisDB) UpdateProjectStatus(pull models.PullRequest, workspace string, repoRelDir string, newStatus models.ProjectPlanStatus) error

UpdateProjectStatus updates pull's status with the latest project results. It returns the new PullStatus object.

func (*RedisDB) UpdatePullWithResults

func (r *RedisDB) UpdatePullWithResults(pull models.PullRequest, newResults []command.ProjectResult) (models.PullStatus, error)

Jump to

Keyboard shortcuts

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