store

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Local

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

Local represents an in-memory storage implementation for managing projects, environments, references, and metrics.

func (*Local) CurrentlyQueuedTasksCount

func (l *Local) CurrentlyQueuedTasksCount(_ context.Context) (count uint64, err error)

CurrentlyQueuedTasksCount returns the count of currently queued tasks.

func (*Local) DelEnvironment

func (l *Local) DelEnvironment(_ context.Context, k schemas.EnvironmentKey) error

DelEnvironment deletes an environment from the local storage.

func (*Local) DelMetric

func (l *Local) DelMetric(_ context.Context, k schemas.MetricKey) error

DelMetric deletes a metric from the local storage.

func (*Local) DelProject

func (l *Local) DelProject(_ context.Context, k schemas.ProjectKey) error

DelProject deletes a project from the local storage.

func (*Local) DelRef

func (l *Local) DelRef(_ context.Context, k schemas.RefKey) error

DelRef deletes a reference from the local storage.

func (*Local) DelRunner added in v0.1.6

func (l *Local) DelRunner(_ context.Context, k schemas.RunnerKey) error

func (*Local) EnvironmentExists

func (l *Local) EnvironmentExists(_ context.Context, k schemas.EnvironmentKey) (bool, error)

EnvironmentExists checks if an environment exists in the local storage.

func (*Local) Environments

func (l *Local) Environments(_ context.Context) (environments schemas.Environments, err error)

Environments retrieves all environments from the local storage.

func (*Local) EnvironmentsCount

func (l *Local) EnvironmentsCount(_ context.Context) (int64, error)

EnvironmentsCount returns the count of environments in the local storage.

func (*Local) ExecutedTasksCount

func (l *Local) ExecutedTasksCount(_ context.Context) (uint64, error)

ExecutedTasksCount returns the count of executed tasks.

func (*Local) GetEnvironment

func (l *Local) GetEnvironment(ctx context.Context, environment *schemas.Environment) error

GetEnvironment retrieves an environment from the local storage.

func (*Local) GetMetric

func (l *Local) GetMetric(ctx context.Context, m *schemas.Metric) error

GetMetric retrieves a metric from the local storage.

func (*Local) GetPipeline added in v0.1.4

func (l *Local) GetPipeline(ctx context.Context, pipeline *schemas.Pipeline) error

GetPipeline retrieves a pipeline from the local storage if it exists.

func (*Local) GetPipelineVariables added in v0.1.4

func (l *Local) GetPipelineVariables(_ context.Context, pipeline schemas.Pipeline) (string, error)

GetPipelineVariables retrieves the variables for a pipeline from the local storage.

func (*Local) GetProject

func (l *Local) GetProject(ctx context.Context, p *schemas.Project) error

GetProject retrieves a project from the local storage.

func (*Local) GetRef

func (l *Local) GetRef(ctx context.Context, ref *schemas.Ref) error

GetRef retrieves a reference from the local storage.

func (*Local) GetRunner added in v0.1.6

func (l *Local) GetRunner(ctx context.Context, runner *schemas.Runner) error

func (*Local) MetricExists

func (l *Local) MetricExists(_ context.Context, k schemas.MetricKey) (bool, error)

MetricExists checks if a metric exists in the local storage.

func (*Local) Metrics

func (l *Local) Metrics(_ context.Context) (metrics schemas.Metrics, err error)

Metrics retrieves all metrics from the local storage.

func (*Local) MetricsCount

func (l *Local) MetricsCount(_ context.Context) (int64, error)

MetricsCount returns the count of metrics in the local storage.

func (*Local) PipelineExists added in v0.1.4

func (l *Local) PipelineExists(_ context.Context, key schemas.PipelineKey) (bool, error)

PipelineExists checks if a pipeline exists in the local storage.

func (*Local) PipelineVariablesExists added in v0.1.4

func (l *Local) PipelineVariablesExists(_ context.Context, pipeline schemas.Pipeline) (bool, error)

PipelineVariablesExists checks if variables for a pipeline exist in the local storage.

func (*Local) ProjectExists

func (l *Local) ProjectExists(_ context.Context, k schemas.ProjectKey) (bool, error)

ProjectExists checks if a project exists in the local storage.

func (*Local) Projects

func (l *Local) Projects(_ context.Context) (projects schemas.Projects, err error)

Projects retrieves all projects from the local storage.

func (*Local) ProjectsCount

func (l *Local) ProjectsCount(_ context.Context) (int64, error)

ProjectsCount returns the count of projects in the local storage.

func (*Local) QueueTask

func (l *Local) QueueTask(_ context.Context, tt schemas.TaskType, uniqueID, _ string) (bool, error)

QueueTask registers that we are queueing the task. It returns true if it managed to schedule it, false if it was already scheduled.

func (*Local) RefExists

func (l *Local) RefExists(_ context.Context, k schemas.RefKey) (bool, error)

RefExists checks if a reference exists in the local storage.

func (*Local) Refs

func (l *Local) Refs(_ context.Context) (refs schemas.Refs, err error)

Refs retrieves all references from the local storage.

func (*Local) RefsCount

func (l *Local) RefsCount(_ context.Context) (int64, error)

RefsCount returns the count of references in the local storage.

func (*Local) RunnerExists added in v0.1.6

func (l *Local) RunnerExists(_ context.Context, k schemas.RunnerKey) (bool, error)

func (*Local) Runners added in v0.1.6

func (l *Local) Runners(_ context.Context) (runners schemas.Runners, err error)

func (*Local) RunnersCount added in v0.1.6

func (l *Local) RunnersCount(_ context.Context) (int64, error)

func (*Local) SetEnvironment

func (l *Local) SetEnvironment(_ context.Context, environment schemas.Environment) error

SetEnvironment stores an environment in the local storage.

func (*Local) SetMetric

func (l *Local) SetMetric(_ context.Context, m schemas.Metric) error

SetMetric stores a metric in the local storage.

func (*Local) SetPipeline added in v0.1.4

func (l *Local) SetPipeline(_ context.Context, pipeline schemas.Pipeline) error

func (*Local) SetPipelineVariables added in v0.1.4

func (l *Local) SetPipelineVariables(_ context.Context, pipeline schemas.Pipeline, variables string) error

SetPipelineVariables sets the variables for a pipeline in the local storage.

func (*Local) SetProject

func (l *Local) SetProject(_ context.Context, p schemas.Project) error

SetProject stores a project in the local storage.

func (*Local) SetRef

func (l *Local) SetRef(_ context.Context, ref schemas.Ref) error

SetRef stores a reference in the local storage.

func (*Local) SetRunner added in v0.1.6

func (l *Local) SetRunner(_ context.Context, runner schemas.Runner) error

func (*Local) UnqueueTask

func (l *Local) UnqueueTask(_ context.Context, tt schemas.TaskType, uniqueID string) error

UnqueueTask removes the task from the tracker.

type Redis

type Redis struct {
	*redis.Client
}

Redis represents a Redis client wrapper.

func (*Redis) CurrentlyQueuedTasksCount

func (r *Redis) CurrentlyQueuedTasksCount(ctx context.Context) (count uint64, err error)

CurrentlyQueuedTasksCount returns the count of currently queued tasks.

func (*Redis) DelEnvironment

func (r *Redis) DelEnvironment(ctx context.Context, k schemas.EnvironmentKey) error

DelEnvironment deletes an environment from Redis.

func (*Redis) DelMetric

func (r *Redis) DelMetric(ctx context.Context, k schemas.MetricKey) error

DelMetric deletes a metric from Redis.

func (*Redis) DelProject

func (r *Redis) DelProject(ctx context.Context, k schemas.ProjectKey) error

DelProject deletes a project from Redis.

func (*Redis) DelRef

func (r *Redis) DelRef(ctx context.Context, k schemas.RefKey) error

DelRef deletes a reference from Redis.

func (*Redis) DelRunner added in v0.1.6

func (r *Redis) DelRunner(ctx context.Context, rk schemas.RunnerKey) error

DelRunner deletes a runner from Redis.

func (*Redis) EnvironmentExists

func (r *Redis) EnvironmentExists(ctx context.Context, k schemas.EnvironmentKey) (bool, error)

EnvironmentExists checks if an environment exists in Redis.

func (*Redis) Environments

func (r *Redis) Environments(ctx context.Context) (schemas.Environments, error)

Environments retrieves all environments from Redis.

func (*Redis) EnvironmentsCount

func (r *Redis) EnvironmentsCount(ctx context.Context) (int64, error)

EnvironmentsCount returns the count of environments in Redis.

func (*Redis) ExecutedTasksCount

func (r *Redis) ExecutedTasksCount(ctx context.Context) (uint64, error)

ExecutedTasksCount returns the count of executed tasks.

func (*Redis) GetEnvironment

func (r *Redis) GetEnvironment(ctx context.Context, e *schemas.Environment) error

GetEnvironment retrieves an environment from Redis.

func (*Redis) GetMetric

func (r *Redis) GetMetric(ctx context.Context, m *schemas.Metric) error

GetMetric retrieves a metric from Redis.

func (*Redis) GetPipeline added in v0.1.4

func (r *Redis) GetPipeline(ctx context.Context, pipeline *schemas.Pipeline) error

func (*Redis) GetPipelineVariables added in v0.1.4

func (r *Redis) GetPipelineVariables(ctx context.Context, pipeline schemas.Pipeline) (string, error)

func (*Redis) GetProject

func (r *Redis) GetProject(ctx context.Context, p *schemas.Project) error

GetProject retrieves a project from Redis.

func (*Redis) GetRef

func (r *Redis) GetRef(ctx context.Context, ref *schemas.Ref) error

GetRef retrieves a reference from Redis.

func (*Redis) GetRunner added in v0.1.6

func (r *Redis) GetRunner(ctx context.Context, ru *schemas.Runner) error

GetRunner retrieves a runner from Redis.

func (*Redis) KeepaliveExists

func (r *Redis) KeepaliveExists(ctx context.Context, uuid string) (bool, error)

KeepaliveExists returns whether a keepalive exists or not for a particular UUID.

func (*Redis) MetricExists

func (r *Redis) MetricExists(ctx context.Context, k schemas.MetricKey) (bool, error)

MetricExists checks if a metric exists in Redis.

func (*Redis) Metrics

func (r *Redis) Metrics(ctx context.Context) (schemas.Metrics, error)

Metrics retrieves all metrics from Redis.

func (*Redis) MetricsCount

func (r *Redis) MetricsCount(ctx context.Context) (int64, error)

MetricsCount returns the count of metrics in Redis.

func (*Redis) PipelineExists added in v0.1.4

func (r *Redis) PipelineExists(ctx context.Context, key schemas.PipelineKey) (bool, error)

func (*Redis) PipelineVariablesExists added in v0.1.4

func (r *Redis) PipelineVariablesExists(ctx context.Context, pipeline schemas.Pipeline) (bool, error)

func (*Redis) ProjectExists

func (r *Redis) ProjectExists(ctx context.Context, k schemas.ProjectKey) (bool, error)

ProjectExists checks if a project exists in Redis.

func (*Redis) Projects

func (r *Redis) Projects(ctx context.Context) (schemas.Projects, error)

Projects retrieves all projects from Redis.

func (*Redis) ProjectsCount

func (r *Redis) ProjectsCount(ctx context.Context) (int64, error)

ProjectsCount returns the count of projects in Redis.

func (*Redis) QueueTask

func (r *Redis) QueueTask(ctx context.Context, tt schemas.TaskType, taskUUID, processUUID string) (set bool, err error)

QueueTask registers that we are queueing the task. It returns true if it managed to schedule it, false if it was already scheduled.

func (*Redis) RefExists

func (r *Redis) RefExists(ctx context.Context, k schemas.RefKey) (bool, error)

RefExists checks if a reference exists in Redis.

func (*Redis) Refs

func (r *Redis) Refs(ctx context.Context) (schemas.Refs, error)

Refs retrieves all references from Redis.

func (*Redis) RefsCount

func (r *Redis) RefsCount(ctx context.Context) (int64, error)

RefsCount returns the count of references in Redis.

func (*Redis) RunnerExists added in v0.1.6

func (r *Redis) RunnerExists(ctx context.Context, rk schemas.RunnerKey) (bool, error)

RunnerExists checks if an runner exists in Redis.

func (*Redis) Runners added in v0.1.6

func (r *Redis) Runners(ctx context.Context) (schemas.Runners, error)

Runners retrieves all runners from Redis.

func (*Redis) RunnersCount added in v0.1.6

func (r *Redis) RunnersCount(ctx context.Context) (int64, error)

RunnersCount returns the count of runner in Redis.

func (*Redis) SetEnvironment

func (r *Redis) SetEnvironment(ctx context.Context, e schemas.Environment) error

SetEnvironment stores an environment in Redis.

func (*Redis) SetKeepalive

func (r *Redis) SetKeepalive(ctx context.Context, uuid string, ttl time.Duration) (bool, error)

SetKeepalive sets a key with a UUID corresponding to the currently running process.

func (*Redis) SetMetric

func (r *Redis) SetMetric(ctx context.Context, m schemas.Metric) error

SetMetric stores a metric in Redis.

func (*Redis) SetPipeline added in v0.1.4

func (r *Redis) SetPipeline(ctx context.Context, pipeline schemas.Pipeline) error

func (*Redis) SetPipelineVariables added in v0.1.4

func (r *Redis) SetPipelineVariables(ctx context.Context, pipeline schemas.Pipeline, variables string) error

func (*Redis) SetProject

func (r *Redis) SetProject(ctx context.Context, p schemas.Project) error

SetProject stores a project in Redis.

func (*Redis) SetRef

func (r *Redis) SetRef(ctx context.Context, ref schemas.Ref) error

SetRef stores a reference in Redis.

func (*Redis) SetRunner added in v0.1.6

func (r *Redis) SetRunner(ctx context.Context, ru schemas.Runner) error

SetRunner stores an runner in Redis.

func (*Redis) UnqueueTask

func (r *Redis) UnqueueTask(ctx context.Context, tt schemas.TaskType, taskUUID string) (err error)

UnqueueTask removes the task from the tracker.

type Store

type Store interface {
	// Methods for manipulating projects
	SetProject(ctx context.Context, p schemas.Project) error                // SetProject Stores a project
	DelProject(ctx context.Context, pk schemas.ProjectKey) error            // DelProject Deletes a project
	GetProject(ctx context.Context, p *schemas.Project) error               // GetProject Retrieves a project
	ProjectExists(ctx context.Context, pk schemas.ProjectKey) (bool, error) // ProjectExists Checks the existence of a project
	Projects(ctx context.Context) (schemas.Projects, error)                 // Projects Retrieves all projects
	ProjectsCount(ctx context.Context) (int64, error)                       // ProjectsCount Counts the number of projects

	// Methods for manipulating environments
	SetEnvironment(ctx context.Context, e schemas.Environment) error                // SetEnvironment Stores an environment
	DelEnvironment(ctx context.Context, ek schemas.EnvironmentKey) error            // DelEnvironment Deletes an environment
	GetEnvironment(ctx context.Context, e *schemas.Environment) error               // GetEnvironment Retrieves an environment
	EnvironmentExists(ctx context.Context, ek schemas.EnvironmentKey) (bool, error) // EnvironmentExists Checks the existence of an environment
	Environments(ctx context.Context) (schemas.Environments, error)                 // Environments Retrieves all environments
	EnvironmentsCount(ctx context.Context) (int64, error)                           // EnvironmentsCount Counts the number of environments

	// Methods for manipulating runners
	SetRunner(ctx context.Context, r schemas.Runner) error                // SetRunner Stores an environment
	DelRunner(ctx context.Context, rk schemas.RunnerKey) error            // DelRunner Deletes an environment
	GetRunner(ctx context.Context, r *schemas.Runner) error               // GetRunner Retrieves an environment
	RunnerExists(ctx context.Context, rk schemas.RunnerKey) (bool, error) // RunnerExists Checks the existence of an environment
	Runners(ctx context.Context) (schemas.Runners, error)                 // Environments Retrieves all environments
	RunnersCount(ctx context.Context) (int64, error)                      // RunnersCount Counts the number of environments

	// Methods for manipulating references
	SetRef(ctx context.Context, r schemas.Ref) error                // SetRef Stores a reference
	DelRef(ctx context.Context, rk schemas.RefKey) error            // DelRef Deletes a reference
	GetRef(ctx context.Context, r *schemas.Ref) error               // GetRef Retrieves a reference
	RefExists(ctx context.Context, rk schemas.RefKey) (bool, error) // RefExists Checks the existence of a reference
	Refs(ctx context.Context) (schemas.Refs, error)                 // Refs Retrieves all references
	RefsCount(ctx context.Context) (int64, error)                   // RefsCount Counts the number of references

	// Methods for manipulating metrics
	SetMetric(ctx context.Context, m schemas.Metric) error                // SetMetric Stores a metric
	DelMetric(ctx context.Context, mk schemas.MetricKey) error            // DelMetric Deletes a metric
	GetMetric(ctx context.Context, m *schemas.Metric) error               // GetMetric Retrieves a metric
	MetricExists(ctx context.Context, mk schemas.MetricKey) (bool, error) // MetricExists Checks the existence of a metric
	Metrics(ctx context.Context) (schemas.Metrics, error)                 // Metrics Retrieves all metrics
	MetricsCount(ctx context.Context) (int64, error)                      // MetricsCount Counts the number of metrics

	// Methods for manipulating Pipelines
	SetPipeline(ctx context.Context, pipeline schemas.Pipeline) error                            // SetPipeline sets a pipeline in the storage.
	GetPipeline(ctx context.Context, pipeline *schemas.Pipeline) error                           // GetPipeline retrieves a pipeline from the storage.
	PipelineExists(ctx context.Context, key schemas.PipelineKey) (bool, error)                   // SetPipelineVariables sets the variables for a pipeline in the storage.
	SetPipelineVariables(ctx context.Context, pipeline schemas.Pipeline, variables string) error // PipelineExists checks if a pipeline exists in the storage.
	GetPipelineVariables(ctx context.Context, pipeline schemas.Pipeline) (string, error)         // GetPipelineVariables retrieves the variables for a pipeline from the storage.
	PipelineVariablesExists(ctx context.Context, pipeline schemas.Pipeline) (bool, error)        // PipelineVariablesExists checks if variables for a pipeline exist in the storage.

	// Helpers to keep track of currently queued tasks and avoid scheduling them
	// twice at the risk of ending up with loads of dangling goroutines being locked
	QueueTask(ctx context.Context, tt schemas.TaskType, taskUUID, processUUID string) (bool, error) // QueueTask Adds a task to the queue
	UnqueueTask(ctx context.Context, tt schemas.TaskType, taskUUID string) error                    // UnqueueTask Removes a task from the queue
	CurrentlyQueuedTasksCount(ctx context.Context) (uint64, error)                                  // CurrentlyQueuedTasksCount Counts the number of currently queued tasks
	ExecutedTasksCount(ctx context.Context) (uint64, error)                                         // ExecutedTasksCount Counts the number of executed tasks
}

Store is an interface that defines methods for interacting with storage. It includes methods for manipulating projects, environments, references, and metrics.

func New

func New(
	ctx context.Context,
	r *redis.Client,
	projects config.Projects,
) (s Store)

New creates a new store and populates it with the provided projects.

func NewLocalStore

func NewLocalStore() Store

NewLocalStore creates a new instance of local storage.

func NewRedisStore

func NewRedisStore(client *redis.Client) Store

NewRedisStore creates a new instance of storage using Redis.

Jump to

Keyboard shortcuts

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