ateredis

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package ateredis is an ate storage backend built on Redis.

Actors are stored in keys of the form `actor:<actor-id>`. They are stored as DBActor JSON-serialized objects, which lets us manipulate them from Redis lua.

Workers are stored in keys of the form `worker:<namespace>:<pool-name>:<pod-name>`, holding a DBWorker JSON object.

Note that redis lua scripting has a restriction that informed the data design here -- a lua script must predeclare all keys it is going to access. It cannot read one key, then derive another key from the value, and read it. This is why we store the worker status inline in the Actor.

Additionally, redis / valkey in cluster mode have a serious restriction that informs our data model: it is not possible for a single "action" to touch keys that hash to to different cluster slots. This includes lua scripts. The biggest implication here is that it is not possible to atomically mark an actor as scheduled on a worker, and the worker as busy. So we need to be very careful about the order in which we take these actions.

Note also (but I cannot find documentation one way or another) that Redis Lua is not ACID --- power failure, etc may leave us with half of the effects of a script applied.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Persistence

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

Persistence is a service that stores information about applications in Redis.

func NewPersistence

func NewPersistence(redisClient *redis.ClusterClient) *Persistence

NewPersistence creates a new Persistence.

func (*Persistence) AcquireLock

func (s *Persistence) AcquireLock(ctx context.Context, key string, value string, ttl time.Duration) (bool, error)

func (*Persistence) CreateActor

func (s *Persistence) CreateActor(ctx context.Context, actor *ateapipb.Actor) error

func (*Persistence) CreateWorker

func (s *Persistence) CreateWorker(ctx context.Context, worker *ateapipb.Worker) error

func (*Persistence) DebugClearAll

func (s *Persistence) DebugClearAll(ctx context.Context) error

DebugClearAll flushes all data from Redis.

func (*Persistence) DeleteActor

func (s *Persistence) DeleteActor(ctx context.Context, id string) error

func (*Persistence) DeleteWorker

func (s *Persistence) DeleteWorker(ctx context.Context, namespace, pool, pod string) error

func (*Persistence) GetActor

func (s *Persistence) GetActor(ctx context.Context, id string) (*ateapipb.Actor, error)

func (*Persistence) GetWorker

func (s *Persistence) GetWorker(ctx context.Context, namespace, pool, pod string) (*ateapipb.Worker, error)

func (*Persistence) ListActors

func (s *Persistence) ListActors(ctx context.Context) ([]*ateapipb.Actor, error)

func (*Persistence) ListWorkers

func (s *Persistence) ListWorkers(ctx context.Context) ([]*ateapipb.Worker, error)

func (*Persistence) ReleaseLock

func (s *Persistence) ReleaseLock(ctx context.Context, key string, value string) error

func (*Persistence) UpdateActor

func (s *Persistence) UpdateActor(ctx context.Context, actor *ateapipb.Actor, expectedVersion int64) error

func (*Persistence) UpdateWorker

func (s *Persistence) UpdateWorker(ctx context.Context, worker *ateapipb.Worker, expectedVersion int64) error

Jump to

Keyboard shortcuts

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