featurebase/dax/controller/worker.go
Travis Turner ea72396b4d
Remove Node from data model; standardize on Worker (#2366)
* Remove Node from data model; standardize on Worker

This commit does a lot of things, but in general it attempts to simplify
the data model by getting rid of the Node and NodeRole models. Instead,
these will use the Worker model, which itself has individual boolean
fields for role types.

Get rid of roleType in some FreeWorker methods

rename NodeService to WorkerRegistry

simplify the freeworker interface

fix the tests

* Remove DeleteWorker method from workerJobService
2023-04-04 20:20:53 -05:00

40 lines
1.3 KiB
Go

package controller
import (
"github.com/featurebasedb/featurebase/v3/dax"
)
// WorkerRegistry represents a service for managing Nodes. Note that this
// interface mirrors the dax.WorkerRegistry interface, but its methods take
// dax.Transactions rather than Contexts. That's because the dax version of this
// interface is meant to be a the API boundary, where this is an interface for
// use within the Controller.
type WorkerRegistry interface {
AddWorker(dax.Transaction, *dax.Node) error
Worker(dax.Transaction, dax.Address) (*dax.Node, error)
RemoveWorker(dax.Transaction, dax.Address) error
Workers(dax.Transaction) ([]*dax.Node, error)
}
// Ensure type implements interface.
var _ WorkerRegistry = &nopWorkerRegistry{}
// nopWorkerRegistry is a no-op implementation of the WorkerRegistry interface.
type nopWorkerRegistry struct{}
func NewNopWorkerRegistry() *nopWorkerRegistry {
return &nopWorkerRegistry{}
}
func (n *nopWorkerRegistry) AddWorker(dax.Transaction, *dax.Node) error {
return nil
}
func (n *nopWorkerRegistry) Worker(dax.Transaction, dax.Address) (*dax.Node, error) {
return nil, nil
}
func (n *nopWorkerRegistry) RemoveWorker(dax.Transaction, dax.Address) error {
return nil
}
func (n *nopWorkerRegistry) Workers(dax.Transaction) ([]*dax.Node, error) {
return []*dax.Node{}, nil
}