redis

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: Apache-2.0 Imports: 10 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 RedisDB

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

Redis is a database using Redis 6

func New

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

func NewWithClient

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

NewWithClient is used for testing.

func (*RedisDB) CheckCommandLock

func (r *RedisDB) CheckCommandLock(cmdName command.Name) (*command.Lock, 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) 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

UpdatePullWithResults 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