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 ¶
- type Persistence
- func (s *Persistence) AcquireLock(ctx context.Context, key string, value string, ttl time.Duration) (bool, error)
- func (s *Persistence) CreateActor(ctx context.Context, actor *ateapipb.Actor) error
- func (s *Persistence) CreateWorker(ctx context.Context, worker *ateapipb.Worker) error
- func (s *Persistence) DebugClearAll(ctx context.Context) error
- func (s *Persistence) DeleteActor(ctx context.Context, id string) error
- func (s *Persistence) DeleteWorker(ctx context.Context, namespace, pool, pod string) error
- func (s *Persistence) GetActor(ctx context.Context, id string) (*ateapipb.Actor, error)
- func (s *Persistence) GetWorker(ctx context.Context, namespace, pool, pod string) (*ateapipb.Worker, error)
- func (s *Persistence) ListActors(ctx context.Context) ([]*ateapipb.Actor, error)
- func (s *Persistence) ListWorkers(ctx context.Context) ([]*ateapipb.Worker, error)
- func (s *Persistence) ReleaseLock(ctx context.Context, key string, value string) error
- func (s *Persistence) UpdateActor(ctx context.Context, actor *ateapipb.Actor, expectedVersion int64) error
- func (s *Persistence) UpdateWorker(ctx context.Context, worker *ateapipb.Worker, expectedVersion int64) error
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 (*Persistence) CreateActor ¶
func (*Persistence) CreateWorker ¶
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