cli, engine, etcd, lib: Split out the deployer into world

This should hopefully make the refactor into a clean world API a bit
better. Still more to do though!
This commit is contained in:
James Shubin
2025-03-18 04:24:39 -04:00
parent 1a35ab61ca
commit 7ad54fe3e8
5 changed files with 144 additions and 41 deletions

View File

@@ -40,8 +40,16 @@ import (
// GAPI to store state and exchange information throughout the cluster. It is
// the interface each machine uses to communicate with the rest of the world.
type World interface { // TODO: is there a better name for this interface?
// Init sets things up and is called once before any other methods.
Init() error
// Close does some cleanup and is the last method that is ever called.
Close() error
FsWorld
DeployWorld
StrWorld
ResWorld
@@ -60,6 +68,21 @@ type FsWorld interface {
Fs(uri string) (Fs, error)
}
// DeployWorld is a world interface with all of the deploy functions.
type DeployWorld interface {
WatchDeploy(context.Context) (chan error, error)
// TODO: currently unused, but already implemented
//GetDeploys(ctx context.Context) (map[uint64]string, error)
GetDeploy(ctx context.Context, id uint64) (string, error)
GetMaxDeployID(ctx context.Context) (uint64, error)
// TODO: This could be split out to a sub-interface?
AddDeploy(ctx context.Context, id uint64, hash, pHash string, data *string) error
}
// StrWorld is a world interface which is useful for reading, writing, and
// watching strings in a shared, distributed database. It is likely that much of
// the functionality is built upon these primitives.