Documentation
¶
Index ¶
- func WithTTLConfig(opts *RedisTTLConfig) func(*RedisStoreConfig)
- type Local
- func (l *Local) CurrentlyQueuedTasksCount(_ context.Context) (count uint64, err error)
- func (l *Local) DelEnvironment(_ context.Context, k schemas.EnvironmentKey) error
- func (l *Local) DelMetric(_ context.Context, k schemas.MetricKey) error
- func (l *Local) DelProject(_ context.Context, k schemas.ProjectKey) error
- func (l *Local) DelRef(_ context.Context, k schemas.RefKey) error
- func (l *Local) DelRunner(_ context.Context, k schemas.RunnerKey) error
- func (l *Local) DequeueTask(_ context.Context, tt schemas.TaskType, uniqueID string) error
- func (l *Local) EnvironmentExists(_ context.Context, k schemas.EnvironmentKey) (bool, error)
- func (l *Local) Environments(_ context.Context) (environments schemas.Environments, err error)
- func (l *Local) EnvironmentsCount(_ context.Context) (int64, error)
- func (l *Local) ExecutedTasksCount(_ context.Context) (uint64, error)
- func (l *Local) GetEnvironment(ctx context.Context, environment *schemas.Environment) error
- func (l *Local) GetMetric(ctx context.Context, m *schemas.Metric) error
- func (l *Local) GetPipeline(ctx context.Context, pipeline *schemas.Pipeline) error
- func (l *Local) GetPipelineVariables(_ context.Context, pipeline schemas.Pipeline) (string, error)
- func (l *Local) GetProject(ctx context.Context, p *schemas.Project) error
- func (l *Local) GetRef(ctx context.Context, ref *schemas.Ref) error
- func (l *Local) GetRunner(ctx context.Context, runner *schemas.Runner) error
- func (l *Local) HasEnvExpired(ctx context.Context, key schemas.EnvironmentKey) bool
- func (l *Local) HasMetricExpired(ctx context.Context, key schemas.MetricKey) bool
- func (l *Local) HasProjectExpired(ctx context.Context, key schemas.ProjectKey) bool
- func (l *Local) HasRefExpired(ctx context.Context, key schemas.RefKey) bool
- func (l *Local) HasRunnerExpired(ctx context.Context, key schemas.RunnerKey) bool
- func (l *Local) MetricExists(_ context.Context, k schemas.MetricKey) (bool, error)
- func (l *Local) Metrics(_ context.Context) (metrics schemas.Metrics, err error)
- func (l *Local) MetricsCount(_ context.Context) (int64, error)
- func (l *Local) PipelineExists(_ context.Context, key schemas.PipelineKey) (bool, error)
- func (l *Local) PipelineVariablesExists(_ context.Context, pipeline schemas.Pipeline) (bool, error)
- func (l *Local) ProjectExists(_ context.Context, k schemas.ProjectKey) (bool, error)
- func (l *Local) Projects(_ context.Context) (projects schemas.Projects, err error)
- func (l *Local) ProjectsCount(_ context.Context) (int64, error)
- func (l *Local) QueueTask(_ context.Context, tt schemas.TaskType, uniqueID, _ string) (bool, error)
- func (l *Local) RefExists(_ context.Context, k schemas.RefKey) (bool, error)
- func (l *Local) Refs(_ context.Context) (refs schemas.Refs, err error)
- func (l *Local) RefsCount(_ context.Context) (int64, error)
- func (l *Local) RunnerExists(_ context.Context, k schemas.RunnerKey) (bool, error)
- func (l *Local) Runners(_ context.Context) (runners schemas.Runners, err error)
- func (l *Local) RunnersCount(_ context.Context) (int64, error)
- func (l *Local) SetEnvironment(_ context.Context, environment schemas.Environment) error
- func (l *Local) SetMetric(_ context.Context, m schemas.Metric) error
- func (l *Local) SetPipeline(_ context.Context, pipeline schemas.Pipeline) error
- func (l *Local) SetPipelineVariables(_ context.Context, pipeline schemas.Pipeline, variables string) error
- func (l *Local) SetProject(_ context.Context, p schemas.Project) error
- func (l *Local) SetRef(_ context.Context, ref schemas.Ref) error
- func (l *Local) SetRunner(_ context.Context, runner schemas.Runner) error
- type Redis
- func (r *Redis) CurrentlyQueuedTasksCount(ctx context.Context) (count uint64, err error)
- func (r *Redis) DelEnvironment(ctx context.Context, k schemas.EnvironmentKey) error
- func (r *Redis) DelMetric(ctx context.Context, k schemas.MetricKey) error
- func (r *Redis) DelProject(ctx context.Context, k schemas.ProjectKey) error
- func (r *Redis) DelRef(ctx context.Context, k schemas.RefKey) error
- func (r *Redis) DelRunner(ctx context.Context, rk schemas.RunnerKey) error
- func (r *Redis) DequeueTask(ctx context.Context, tt schemas.TaskType, taskUUID string) (err error)
- func (r *Redis) EnvironmentExists(ctx context.Context, k schemas.EnvironmentKey) (bool, error)
- func (r *Redis) Environments(ctx context.Context) (schemas.Environments, error)
- func (r *Redis) EnvironmentsCount(ctx context.Context) (int64, error)
- func (r *Redis) ExecutedTasksCount(ctx context.Context) (uint64, error)
- func (r *Redis) GetEnvironment(ctx context.Context, e *schemas.Environment) error
- func (r *Redis) GetMetric(ctx context.Context, m *schemas.Metric) error
- func (r *Redis) GetPipeline(ctx context.Context, pipeline *schemas.Pipeline) error
- func (r *Redis) GetPipelineVariables(ctx context.Context, pipeline schemas.Pipeline) (string, error)
- func (r *Redis) GetProject(ctx context.Context, p *schemas.Project) error
- func (r *Redis) GetRef(ctx context.Context, ref *schemas.Ref) error
- func (r *Redis) GetRunner(ctx context.Context, ru *schemas.Runner) error
- func (r *Redis) HasEnvExpired(ctx context.Context, key schemas.EnvironmentKey) bool
- func (r *Redis) HasMetricExpired(ctx context.Context, key schemas.MetricKey) bool
- func (r *Redis) HasProjectExpired(ctx context.Context, key schemas.ProjectKey) bool
- func (r *Redis) HasRefExpired(ctx context.Context, key schemas.RefKey) bool
- func (r *Redis) HasRunnerExpired(ctx context.Context, key schemas.RunnerKey) bool
- func (r *Redis) KeepaliveExists(ctx context.Context, uuid string) (bool, error)
- func (r *Redis) MetricExists(ctx context.Context, k schemas.MetricKey) (bool, error)
- func (r *Redis) Metrics(ctx context.Context) (schemas.Metrics, error)
- func (r *Redis) MetricsCount(ctx context.Context) (int64, error)
- func (r *Redis) PipelineExists(ctx context.Context, key schemas.PipelineKey) (bool, error)
- func (r *Redis) PipelineVariablesExists(ctx context.Context, pipeline schemas.Pipeline) (bool, error)
- func (r *Redis) ProjectExists(ctx context.Context, k schemas.ProjectKey) (bool, error)
- func (r *Redis) Projects(ctx context.Context) (schemas.Projects, error)
- func (r *Redis) ProjectsCount(ctx context.Context) (int64, error)
- func (r *Redis) QueueTask(ctx context.Context, tt schemas.TaskType, taskUUID, processUUID string) (set bool, err error)
- func (r *Redis) RefExists(ctx context.Context, k schemas.RefKey) (bool, error)
- func (r *Redis) Refs(ctx context.Context) (schemas.Refs, error)
- func (r *Redis) RefsCount(ctx context.Context) (int64, error)
- func (r *Redis) RunnerExists(ctx context.Context, rk schemas.RunnerKey) (bool, error)
- func (r *Redis) Runners(ctx context.Context) (schemas.Runners, error)
- func (r *Redis) RunnersCount(ctx context.Context) (int64, error)
- func (r *Redis) SetEnvironment(ctx context.Context, e schemas.Environment) error
- func (r *Redis) SetKeepalive(ctx context.Context, uuid string, ttl time.Duration) (bool, error)
- func (r *Redis) SetMetric(ctx context.Context, m schemas.Metric) error
- func (r *Redis) SetPipeline(ctx context.Context, pipeline schemas.Pipeline) error
- func (r *Redis) SetPipelineVariables(ctx context.Context, pipeline schemas.Pipeline, variables string) error
- func (r *Redis) SetProject(ctx context.Context, p schemas.Project) error
- func (r *Redis) SetRef(ctx context.Context, ref schemas.Ref) error
- func (r *Redis) SetRunner(ctx context.Context, ru schemas.Runner) error
- type RedisStoreConfig
- type RedisStoreOptions
- type RedisTTLConfig
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithTTLConfig ¶ added in v0.1.8
func WithTTLConfig(opts *RedisTTLConfig) func(*RedisStoreConfig)
WithTTLConfig is an option function for setting a Redis TTL configuration. It follows the "functional options" pattern, allowing you to configure a RedisStoreConfig instance when creating it.
Example:
cfg := &RedisStoreConfig{}
WithTTLConfig(&RedisTTLConfig{Project: time.Hour})(cfg)
This will set cfg.TTLConfig to the provided TTL configuration.
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 ¶
CurrentlyQueuedTasksCount returns the count of currently queued tasks.
func (*Local) DelEnvironment ¶
DelEnvironment deletes an environment from the local storage.
func (*Local) DelProject ¶
DelProject deletes a project from the local storage.
func (*Local) DequeueTask ¶ added in v0.1.8
DequeueTask removes the task from the tracker.
func (*Local) EnvironmentExists ¶
EnvironmentExists checks if an environment exists in the local storage.
func (*Local) Environments ¶
Environments retrieves all environments from the local storage.
func (*Local) EnvironmentsCount ¶
EnvironmentsCount returns the count of environments in the local storage.
func (*Local) ExecutedTasksCount ¶
ExecutedTasksCount returns the count of executed tasks.
func (*Local) GetEnvironment ¶
GetEnvironment retrieves an environment from the local storage.
func (*Local) GetPipeline ¶ added in v0.1.4
GetPipeline retrieves a pipeline from the local storage if it exists.
func (*Local) GetPipelineVariables ¶ added in v0.1.4
GetPipelineVariables retrieves the variables for a pipeline from the local storage.
func (*Local) GetProject ¶
GetProject retrieves a project from the local storage.
func (*Local) HasEnvExpired ¶ added in v0.1.8
HasEnvExpired always returns false for the Local store. The Local implementation does not manage TTLs for environments.
func (*Local) HasMetricExpired ¶ added in v0.1.8
HasMetricExpired always returns false for the Local store. The Local store does not have time-based key expiration for metrics.
func (*Local) HasProjectExpired ¶ added in v0.1.8
HasProjectExpired always returns false for the Local store. In the in-memory (Local) implementation, keys do not expire automatically, so this method simply indicates that a project has never "expired".
func (*Local) HasRefExpired ¶ added in v0.1.8
HasRefExpired always returns false for the Local store. Since the Local store holds data only in memory without TTL, refs never expire automatically.
func (*Local) HasRunnerExpired ¶ added in v0.1.8
HasRunnerExpired always returns false for the Local store. TTL expiration is only supported in persistent backends like Redis.
func (*Local) MetricExists ¶
MetricExists checks if a metric exists in the local storage.
func (*Local) MetricsCount ¶
MetricsCount returns the count of metrics in the local storage.
func (*Local) PipelineExists ¶ added in v0.1.4
PipelineExists checks if a pipeline exists in the local storage.
func (*Local) PipelineVariablesExists ¶ added in v0.1.4
PipelineVariablesExists checks if variables for a pipeline exist in the local storage.
func (*Local) ProjectExists ¶
ProjectExists checks if a project exists in the local storage.
func (*Local) ProjectsCount ¶
ProjectsCount returns the count of projects in the local storage.
func (*Local) QueueTask ¶
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) RunnerExists ¶ added in v0.1.6
func (*Local) RunnersCount ¶ added in v0.1.6
func (*Local) SetEnvironment ¶
SetEnvironment stores an environment in the local storage.
func (*Local) SetPipeline ¶ added in v0.1.4
SetPipeline ...
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 ¶
SetProject stores a project in the local storage.
type Redis ¶
type Redis struct {
*redis.Client
StoreConfig *RedisStoreConfig
}
Redis represents a Redis client wrapper.
func NewRedisStore ¶
func NewRedisStore(client *redis.Client, opts ...RedisStoreOptions) *Redis
NewRedisStore creates a new instance of storage using Redis.
func (*Redis) CurrentlyQueuedTasksCount ¶
CurrentlyQueuedTasksCount returns the count of currently queued tasks.
func (*Redis) DelEnvironment ¶
DelEnvironment deletes an environment from Redis.
func (*Redis) DelProject ¶
DelProject deletes a project from Redis.
func (*Redis) DequeueTask ¶ added in v0.1.8
DequeueTask removes the task from the tracker.
func (*Redis) EnvironmentExists ¶
EnvironmentExists checks if an environment exists in Redis.
func (*Redis) Environments ¶
Environments retrieves all environments from Redis.
func (*Redis) EnvironmentsCount ¶
EnvironmentsCount returns the count of environments in Redis.
func (*Redis) ExecutedTasksCount ¶
ExecutedTasksCount returns the count of executed tasks.
func (*Redis) GetEnvironment ¶
GetEnvironment retrieves an environment from Redis.
func (*Redis) GetPipeline ¶ added in v0.1.4
func (*Redis) GetPipelineVariables ¶ added in v0.1.4
func (*Redis) GetProject ¶
GetProject retrieves a project from Redis.
func (*Redis) HasEnvExpired ¶ added in v0.1.8
need the method: HasEnvExpired(ctx context.Context, key schemas.RefKey) bool HasEnvExpired checks if an environment key's TTL entry still exists in Redis.
func (*Redis) HasMetricExpired ¶ added in v0.1.8
HasMetricExpired checks if a metric key's TTL entry still exists in Redis.
func (*Redis) HasProjectExpired ¶ added in v0.1.8
HasProjectExpired checks if a project key's TTL entry still exists in Redis. Returns true if the TTL key exists (meaning it has not yet expired), and false otherwise. If there's an error querying Redis, it fails safe and returns false.
func (*Redis) HasRefExpired ¶ added in v0.1.8
HasRefExpired checks if a ref key's TTL entry still exists in Redis.
func (*Redis) HasRunnerExpired ¶ added in v0.1.8
HasRunnerExpired checks if a runner key's TTL entry still exists in Redis.
func (*Redis) KeepaliveExists ¶
KeepaliveExists returns whether a keepalive exists or not for a particular UUID.
func (*Redis) MetricExists ¶
MetricExists checks if a metric exists in Redis.
func (*Redis) MetricsCount ¶
MetricsCount returns the count of metrics in Redis.
func (*Redis) PipelineExists ¶ added in v0.1.4
func (*Redis) PipelineVariablesExists ¶ added in v0.1.4
func (*Redis) ProjectExists ¶
ProjectExists checks if a project exists in Redis.
func (*Redis) ProjectsCount ¶
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) RunnerExists ¶ added in v0.1.6
RunnerExists checks if an runner exists in Redis.
func (*Redis) RunnersCount ¶ added in v0.1.6
RunnersCount returns the count of runner in Redis.
func (*Redis) SetEnvironment ¶
SetEnvironment stores an environment in Redis.
func (*Redis) SetKeepalive ¶
SetKeepalive sets a key with a UUID corresponding to the currently running process.
func (*Redis) SetPipeline ¶ added in v0.1.4
func (*Redis) SetPipelineVariables ¶ added in v0.1.4
func (*Redis) SetProject ¶
SetProject stores a project in Redis.
type RedisStoreConfig ¶ added in v0.1.8
type RedisStoreConfig struct {
// TTLConfig defines how long different types of data should be kept in Redis
// before expiring. If nil, default TTL values will be used.
TTLConfig *RedisTTLConfig
}
RedisStoreConfig represents the configuration for a Redis-based store. It can hold additional options like time-to-live (TTL) settings for different data types.
type RedisStoreOptions ¶ added in v0.1.8
type RedisStoreOptions func(opts *RedisStoreConfig)
RedisStoreOptions defines a function type used to modify a RedisStoreConfig. It follows the "functional options" design pattern, where configuration is applied by passing in functions that mutate a config object.
Any function with this signature can be used to set or override fields in a RedisStoreConfig when initializing a Redis store.
Example:
func WithDefaultTTL(ttl time.Duration) RedisStoreOptions {
return func(cfg *RedisStoreConfig) {
cfg.TTLConfig = &RedisTTLConfig{
Project: ttl,
Environment: ttl,
Runner: ttl,
Refs: ttl,
Metrics: ttl,
}
}
}
type RedisTTLConfig ¶ added in v0.1.8
type RedisTTLConfig struct {
Project time.Duration // Project is the TTL for cached project data.
Environment time.Duration // Environment is the TTL for cached environment data.
Runner time.Duration // Runner is the TTL for cached GitLab runner data.
Refs time.Duration // Refs is the TTL for cached Git references (branches, tags, merge requests).
Metrics time.Duration // Metrics is the TTL for cached metrics data.
}
RedisTTLConfig contains time-to-live (TTL) durations for different cached entities. Each field specifies how long that entity should remain in Redis before being deleted.
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
HasProjectExpired(ctx context.Context, key schemas.ProjectKey) bool
// 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
HasEnvExpired(ctx context.Context, key schemas.EnvironmentKey) bool
// Methods for manipulating runners
SetRunner(ctx context.Context, r schemas.Runner) error // SetRunner Stores a runner
DelRunner(ctx context.Context, rk schemas.RunnerKey) error // DelRunner Deletes a runner
GetRunner(ctx context.Context, r *schemas.Runner) error // GetRunner Retrieves a runner
RunnerExists(ctx context.Context, rk schemas.RunnerKey) (bool, error) // RunnerExists Checks the existence of an environment
Runners(ctx context.Context) (schemas.Runners, error) // Runners Retrieves all runners
RunnersCount(ctx context.Context) (int64, error) // RunnersCount Counts the number of runners
HasRunnerExpired(ctx context.Context, key schemas.RunnerKey) bool
// 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
HasRefExpired(ctx context.Context, key schemas.RefKey) bool
// 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
HasMetricExpired(ctx context.Context, key schemas.MetricKey) bool
// 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
DequeueTask(ctx context.Context, tt schemas.TaskType, taskUUID string) error // DequeueTask 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)
}
Store is an interface that defines methods for interacting with storage. It includes methods for manipulating projects, environments, references, and metrics.
func NewLocalStore ¶
func NewLocalStore() Store
NewLocalStore creates a new instance of local storage.