store

package
v0.0.0-...-234d38c Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: Apache-2.0 Imports: 9 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
}

func (*Local) CurrentlyQueuedTasksCount

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

CurrentlyQueuedTasksCount ..

func (*Local) DelMetric

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

DelMetric ..

func (*Local) ExecutedTasksCount

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

ExecutedTasksCount ..

func (*Local) GetMetric

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

GetMetric ..

func (*Local) MetricExists

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

MetricExists ..

func (*Local) Metrics

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

Metrics ..

func (*Local) MetricsCount

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

MetricsCount ..

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) SetMetric

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

SetMetric ..

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 ..

func (*Redis) CurrentlyQueuedTasksCount

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

CurrentlyQueuedTasksCount ..

func (*Redis) DelMetric

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

DelMetric ..

func (*Redis) ExecutedTasksCount

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

ExecutedTasksCount ..

func (*Redis) GetMetric

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

GetMetric ..

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 ..

func (*Redis) Metrics

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

Metrics ..

func (*Redis) MetricsCount

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

MetricsCount ..

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) SetKeepalive

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

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

func (*Redis) SetMetric

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

SetMetric ..

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 {
	// Metrics ..
	Metrics(context.Context) (schemas.Metrics, error)
	SetMetric(context.Context, schemas.Metric) error
	DelMetric(context.Context, schemas.MetricKey) error
	GetMetric(context.Context, *schemas.Metric) error
	MetricExists(context.Context, schemas.MetricKey) (bool, error)
	MetricsCount(context.Context) (int64, error)
	// QueueTask 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(context.Context, schemas.TaskType, string, string) (bool, error)
	UnqueueTask(context.Context, schemas.TaskType, string) error
	CurrentlyQueuedTasksCount(context.Context) (uint64, error)
	ExecutedTasksCount(context.Context) (uint64, error)
}

Store ..

func New

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

New creates a new store and populates it with provided []schemas.Project.

func NewLocalStore

func NewLocalStore() Store

NewLocalStore ..

func NewRedisStore

func NewRedisStore(client *redis.Client) Store

NewRedisStore ..

Jump to

Keyboard shortcuts

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