mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
* Support Drop Table in serverless (include Snapshotter, Writelogger) * Finish Database methods Things like: - `Databases` - `DatabaseByID` - `DatabaseByName` - `DropDatabase` * Change Poller to use NodeService instead of its own map Instead of the Poller maintaining its own map of Addresses to poll, this commit changes the Poller to use the NodeService interface to get all known nodes from the Controller. The next commit needs to: Next, the logic in the boltdb NodeService implementation was moved to the boltdb Balancer implementation. That way, the Balancer can be the source of truth for all things nodes/workers/jobs. * Move NodeService from Controller to Balancer This commit moves the implementation of the NodeService into the Balancer, and aligns `Balancer.AddWorker` with `NodeService.CreateNode` so that they stay in sync. (Same for `Balancer.RemoveWorker` and `NodeService.DeleteNode`). * fix import of private repo * Fix go vet issues * Fix bug in DeregisterNode We need to remove the node from the NodeService even if it's not assigned to a database. The logic had a bug in it. This also adds some no-op implementations for SnapshotService and WriteloggerService. If a directory was not configured for that, then the computer node would panic on trying to read from the Snapshotter upon receiving a Directive. * queryer response content-type: json * Add support for NULL to WriteloggerDir and SnapshotterDir configs This commit changes the way WriteLoggerDir and SnapshotterDir are handled. If value is empty `""`, an error will be returned on computer startup. If value is `"NULL"`, a no-op implementation of the service will be used. This would be for a case that wanted to run serverless on-prem with no durable storage. Finally, any other value will be used as the directory to use. Some things which aren't considered here and may result in unexpected behavior: - a value with spaces `" "` - any "null" which is not "NULL"... like lowercase. * Finish the DropTable test * Change "disable service" value to case-insensitive "off" This commit also removes an unnecessary sleep in the tests. * Fix docker-compose variables for IDK test Co-authored-by: Matthew Jaffee <jaffee@pilosa.com>
102 lines
4.3 KiB
Go
102 lines
4.3 KiB
Go
package dax
|
|
|
|
import "context"
|
|
|
|
// Schemar is similar to the pilosa.SchemaAPI interface, but it takes
|
|
// QualifiedDatabaseIDs into account. Note that it is also similar to the
|
|
// schemar.Schemar interface, but that is used internally, typically within the
|
|
// Controller, and it takes Transactions rather than a Context, because its
|
|
// methods are assumed to be used as part of a larger request.
|
|
// TODO(tlt): clean up the mds/controller/schemar Schemar interface confusion.
|
|
type Schemar interface {
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// Database methods
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
CreateDatabase(context.Context, *QualifiedDatabase) error
|
|
DropDatabase(context.Context, QualifiedDatabaseID) error
|
|
|
|
DatabaseByName(ctx context.Context, orgID OrganizationID, dbname DatabaseName) (*QualifiedDatabase, error)
|
|
DatabaseByID(ctx context.Context, qdbid QualifiedDatabaseID) (*QualifiedDatabase, error)
|
|
|
|
// Databases returns a list of databases. If the list of DatabaseIDs is
|
|
// empty, all databases will be returned. If greater than zero DatabaseIDs
|
|
// are passed in the second argument, only databases matching those IDs will
|
|
// be returned.
|
|
Databases(context.Context, OrganizationID, ...DatabaseID) ([]*QualifiedDatabase, error)
|
|
|
|
// SetDatabaseOptions(context.Context, QualifiedDatabaseID, DatabaseOptions) error
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// Table methods
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
CreateTable(ctx context.Context, qtbl *QualifiedTable) error
|
|
DropTable(ctx context.Context, qtid QualifiedTableID) error
|
|
|
|
TableByName(ctx context.Context, qdbid QualifiedDatabaseID, tname TableName) (*QualifiedTable, error)
|
|
TableByID(ctx context.Context, qtid QualifiedTableID) (*QualifiedTable, error)
|
|
|
|
// Tables returns a list of tables. If the qualifiers DatabaseID is empty,
|
|
// all tables in the org will be returned. If the OrganizationID is empty,
|
|
// all tables will be returned. If both are populated, only tables in that
|
|
// database will be returned. If greater than zero table IDs are passed in
|
|
// the third argument, only tables matching those IDs will be returned.
|
|
Tables(ctx context.Context, qdbid QualifiedDatabaseID, tids ...TableID) ([]*QualifiedTable, error)
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// Field methods
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
CreateField(ctx context.Context, qtid QualifiedTableID, fld *Field) error
|
|
DropField(ctx context.Context, qtid QualifiedTableID, fname FieldName) error
|
|
}
|
|
|
|
//////////////////////////////////////////////
|
|
|
|
// Ensure type implements interface.
|
|
var _ Schemar = &NopSchemar{}
|
|
|
|
// NopSchemar is a no-op implementation of the Schemar interface.
|
|
type NopSchemar struct{}
|
|
|
|
func NewNopSchemar() *NopSchemar {
|
|
return &NopSchemar{}
|
|
}
|
|
|
|
func (s *NopSchemar) CreateDatabase(context.Context, *QualifiedDatabase) error {
|
|
return nil
|
|
}
|
|
func (s *NopSchemar) DropDatabase(context.Context, QualifiedDatabaseID) error {
|
|
return nil
|
|
}
|
|
func (s *NopSchemar) DatabaseByName(ctx context.Context, orgID OrganizationID, dbname DatabaseName) (*QualifiedDatabase, error) {
|
|
return nil, nil
|
|
}
|
|
func (s *NopSchemar) DatabaseByID(ctx context.Context, qdbid QualifiedDatabaseID) (*QualifiedDatabase, error) {
|
|
return nil, nil
|
|
}
|
|
func (s *NopSchemar) Databases(context.Context, OrganizationID, ...DatabaseID) ([]*QualifiedDatabase, error) {
|
|
return nil, nil
|
|
}
|
|
func (s *NopSchemar) TableByName(context.Context, QualifiedDatabaseID, TableName) (*QualifiedTable, error) {
|
|
return nil, nil
|
|
}
|
|
func (s *NopSchemar) TableByID(ctx context.Context, qtid QualifiedTableID) (*QualifiedTable, error) {
|
|
return nil, nil
|
|
}
|
|
func (s *NopSchemar) Tables(ctx context.Context, qdbid QualifiedDatabaseID, tids ...TableID) ([]*QualifiedTable, error) {
|
|
return nil, nil
|
|
}
|
|
func (s *NopSchemar) CreateTable(ctx context.Context, qtbl *QualifiedTable) error {
|
|
return nil
|
|
}
|
|
func (s *NopSchemar) DropTable(ctx context.Context, qtid QualifiedTableID) error {
|
|
return nil
|
|
}
|
|
func (s *NopSchemar) CreateField(ctx context.Context, qtid QualifiedTableID, fld *Field) error {
|
|
return nil
|
|
}
|
|
func (s *NopSchemar) DropField(ctx context.Context, qtid QualifiedTableID, fld FieldName) error {
|
|
return nil
|
|
}
|