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>
100 lines
3.3 KiB
Go
100 lines
3.3 KiB
Go
package computer
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
|
|
"github.com/featurebasedb/featurebase/v3/dax"
|
|
)
|
|
|
|
// Registrar represents the methods which Computer uses to register itself with
|
|
// MDS.
|
|
type Registrar interface {
|
|
RegisterNode(ctx context.Context, node *dax.Node) error
|
|
CheckInNode(ctx context.Context, node *dax.Node) error
|
|
}
|
|
|
|
// WritelogService represents the WritelogService methods which Computer uses.
|
|
// These are typically implemented by the Writelogger client.
|
|
type WritelogService interface {
|
|
AppendMessage(bucket string, key string, version int, msg []byte) error
|
|
LogReader(bucket string, key string, version int) (io.ReadCloser, error)
|
|
LogReaderFrom(bucket string, key string, version int, offset int) (io.ReadCloser, error)
|
|
DeleteLog(bucket string, key string, version int) error
|
|
List(bucket, key string) ([]WriteLogInfo, error)
|
|
Lock(bucket, key string) error
|
|
Unlock(bucket, key string) error
|
|
}
|
|
|
|
// SnapshotService represents the SnapshotService methods which Computer uses.
|
|
// These are typically implemented by both the Snapshotter client.
|
|
type SnapshotService interface {
|
|
Read(bucket string, key string, version int) (io.ReadCloser, error)
|
|
Write(bucket string, key string, version int, rc io.ReadCloser) error
|
|
WriteTo(bucket string, key string, version int, wrTo io.WriterTo) error
|
|
List(bucket, key string) ([]SnapInfo, error)
|
|
}
|
|
|
|
// SnapInfo holds metadata about a snapshot.
|
|
type SnapInfo struct {
|
|
Version int
|
|
// Date time.Time
|
|
}
|
|
|
|
// WriteLogInfo holds metadata about a write log.
|
|
type WriteLogInfo SnapInfo
|
|
|
|
// LogMessage is implemented by a variety of types which can be serialized as
|
|
// messages to the Writelogger.
|
|
type LogMessage interface{}
|
|
|
|
/////////// No-op implementations of the interfaces //////////////
|
|
|
|
// nopWritelogService is a no-op implementation of the WritelogService
|
|
// interface.
|
|
type nopWritelogService struct{}
|
|
|
|
func NewNopWritelogService() *nopWritelogService {
|
|
return &nopWritelogService{}
|
|
}
|
|
func (b *nopWritelogService) AppendMessage(bucket string, key string, version int, msg []byte) error {
|
|
return nil
|
|
}
|
|
func (b *nopWritelogService) LogReader(bucket string, key string, version int) (io.ReadCloser, error) {
|
|
return nil, nil
|
|
}
|
|
func (b *nopWritelogService) LogReaderFrom(bucket string, key string, version int, offset int) (io.ReadCloser, error) {
|
|
return nil, nil
|
|
}
|
|
func (b *nopWritelogService) DeleteLog(bucket string, key string, version int) error {
|
|
return nil
|
|
}
|
|
func (b *nopWritelogService) List(bucket, key string) ([]WriteLogInfo, error) {
|
|
return nil, nil
|
|
}
|
|
func (b *nopWritelogService) Lock(bucket, key string) error {
|
|
return nil
|
|
}
|
|
func (b *nopWritelogService) Unlock(bucket, key string) error {
|
|
return nil
|
|
}
|
|
|
|
// nopSnapshotterService is a no-op implementation of the WritelogService
|
|
// interface.
|
|
type nopSnapshotterService struct{}
|
|
|
|
func NewNopSnapshotterService() *nopSnapshotterService {
|
|
return &nopSnapshotterService{}
|
|
}
|
|
func (b *nopSnapshotterService) Read(bucket string, key string, version int) (io.ReadCloser, error) {
|
|
return nil, nil
|
|
}
|
|
func (b *nopSnapshotterService) Write(bucket string, key string, version int, rc io.ReadCloser) error {
|
|
return nil
|
|
}
|
|
func (b *nopSnapshotterService) WriteTo(bucket string, key string, version int, wrTo io.WriterTo) error {
|
|
return nil
|
|
}
|
|
func (b *nopSnapshotterService) List(bucket, key string) ([]SnapInfo, error) {
|
|
return nil, nil
|
|
}
|