mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
* 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
62 lines
1.5 KiB
Go
62 lines
1.5 KiB
Go
package dax
|
|
|
|
// RoleType represents a role type which a worker node can act as.
|
|
type RoleType string
|
|
|
|
const (
|
|
RoleTypeCompute RoleType = "compute"
|
|
RoleTypeTranslate RoleType = "translate"
|
|
RoleTypeQuery RoleType = "query"
|
|
)
|
|
|
|
var (
|
|
AllRoleTypes = []RoleType{RoleTypeCompute, RoleTypeTranslate, RoleTypeQuery}
|
|
)
|
|
|
|
// RoleTypes is a list of RoleType, used primarily to introduce helper methods
|
|
// on the list.
|
|
type RoleTypes []RoleType
|
|
|
|
// Contains returns true if the given RoleType is in RoleTypes.
|
|
func (rt RoleTypes) Contains(t RoleType) bool {
|
|
for i := range rt {
|
|
if rt[i] == t {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
// Role is an interface for any role which a worker node can assume.
|
|
type Role interface {
|
|
Type() RoleType
|
|
}
|
|
|
|
// Ensure type implements interface.
|
|
var _ Role = (*ComputeRole)(nil)
|
|
var _ Role = (*TranslateRole)(nil)
|
|
|
|
// ComputeRole is a role specific to compute nodes.
|
|
type ComputeRole struct {
|
|
TableKey TableKey `json:"table-key"`
|
|
Shards ShardNums `json:"shards"`
|
|
}
|
|
|
|
// Type returns the type for ComputeRole. This is mainly to implement the Role
|
|
// interface.
|
|
func (cr *ComputeRole) Type() RoleType {
|
|
return RoleTypeCompute
|
|
}
|
|
|
|
// TranslateRole is a role specific to translate nodes.
|
|
type TranslateRole struct {
|
|
TableKey TableKey `json:"table-key"`
|
|
Partitions PartitionNums `json:"partitions"`
|
|
Fields []FieldName `json:"fields"`
|
|
}
|
|
|
|
// Type returns the type for TranslateRole. This is mainly to implement the Role
|
|
// interface.
|
|
func (cr *TranslateRole) Type() RoleType {
|
|
return RoleTypeTranslate
|
|
}
|