engine: Split off resource world interface

This commit is contained in:
James Shubin
2025-03-18 03:14:17 -04:00
parent 1edff3b3f5
commit 692db084e4

View File

@@ -40,10 +40,7 @@ import (
// GAPI to store state and exchange information throughout the cluster. It is // 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. // 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? type World interface { // TODO: is there a better name for this interface?
ResWatch(context.Context) (chan error, error) ResWorld
ResExport(context.Context, []Res) error
// FIXME: should this method take a "filter" data struct instead of many args?
ResCollect(ctx context.Context, hostnameFilter, kindFilter []string) ([]Res, error)
StrWatch(ctx context.Context, namespace string) (chan error, error) StrWatch(ctx context.Context, namespace string) (chan error, error)
StrIsNotExist(error) bool StrIsNotExist(error) bool
@@ -69,6 +66,16 @@ type World interface { // TODO: is there a better name for this interface?
Fs(uri string) (Fs, error) Fs(uri string) (Fs, error)
} }
// ResWorld is a world interface that lets us store, pull and watch resources in
// a distributed database.
// XXX: These API's are likely to change.
type ResWorld interface {
ResWatch(context.Context) (chan error, error)
ResExport(context.Context, []Res) error
// FIXME: should this method take a "filter" data struct instead of many args?
ResCollect(ctx context.Context, hostnameFilter, kindFilter []string) ([]Res, error)
}
// EtcdWorld is a world interface that should be implemented if the world // EtcdWorld is a world interface that should be implemented if the world
// backend is implementing etcd, and if it supports dynamically resizing things. // backend is implementing etcd, and if it supports dynamically resizing things.
// TODO: In theory we could generalize this to support other backends, but lets // TODO: In theory we could generalize this to support other backends, but lets