Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Manifold ¶
func Manifold(config ManifoldConfig) dependency.Manifold
Manifold returns a dependency manifold that runs the dbaccessor worker, using the resource names defined in the supplied config.
func NewWorker ¶
func NewWorker(cfg WorkerConfig) (*dbReplWorker, error)
NewWorker creates a new dbaccessor worker.
Types ¶
type DBApp ¶
type DBApp interface {
// Open the dqlite database with the given name
Open(context.Context, string) (*sql.DB, error)
}
DBApp describes methods of a Dqlite database application, required to run this host as a Dqlite node.
type DBGetter ¶
type DBGetter interface {
// GetDB returns a sql.DB reference for the dqlite-backed database that
// contains the data for the specified namespace.
// A NotFound error is returned if the worker is unaware of the requested DB.
GetDB(namespace string) (database.TxnRunner, error)
}
DBGetter describes the ability to supply a sql.DB reference for a particular database.
type ManifoldConfig ¶
type ManifoldConfig struct {
AgentName string
Clock clock.Clock
Logger logger.Logger
NewApp NewAppFunc
NewDBReplWorker NewDBReplWorkerFunc
NewNodeManager NewNodeManagerFunc
}
ManifoldConfig contains: - The names of other manifolds on which the DB accessor depends. - Other dependencies from ManifoldsConfig required by the worker.
func (ManifoldConfig) Validate ¶
func (cfg ManifoldConfig) Validate() error
type NewAppFunc ¶
NewAppFunc creates a new Dqlite application.
type NewDBReplWorkerFunc ¶
type NewDBReplWorkerFunc func(context.Context, DBApp, string, ...TrackedDBWorkerOption) (TrackedDB, error)
NewDBReplWorkerFunc creates a tracked db worker.
type NewNodeManagerFunc ¶
type NewNodeManagerFunc func(agent.Config, logger.Logger, coredatabase.SlowQueryLogger) NodeManager
NewNodeManagerFunc creates a NodeManager
type NodeManager ¶
type NodeManager interface {
// EnsureDataDir ensures that a directory for Dqlite data exists at
// a path determined by the agent config, then returns that path.
EnsureDataDir() (string, error)
// DqliteSQLDriver returns a Dqlite SQL driver that can be used to
// connect to the Dqlite cluster. This is a read only connection, which is
// intended to be used for running queries against the Dqlite cluster (REPL).
DqliteSQLDriver(ctx context.Context) (driver.Driver, error)
}
NodeManager creates Dqlite `App` initialisation arguments and options.
func CAASNodeManager ¶
func CAASNodeManager(cfg agent.Config, logger logger.Logger, slowQueryLogger coredatabase.SlowQueryLogger) NodeManager
CAASNodeManager returns a NodeManager that is configured to use the loopback address for Dqlite.
func IAASNodeManager ¶
func IAASNodeManager(cfg agent.Config, logger logger.Logger, slowQueryLogger coredatabase.SlowQueryLogger) NodeManager
IAASNodeManager returns a NodeManager that is configured to use the cloud-local TLS terminated address for Dqlite.
type TrackedDB ¶
type TrackedDB interface {
coredatabase.TxnRunner
worker.Worker
}
TrackedDB defines the union of a TxnRunner and a worker.Worker interface. This is local to the package, allowing for better testing of the underlying trackedDB worker.
func NewTrackedDBWorker ¶
func NewTrackedDBWorker( ctx context.Context, dbApp DBApp, namespace string, opts ...TrackedDBWorkerOption, ) (TrackedDB, error)
NewTrackedDBWorker creates a new TrackedDBWorker
type TrackedDBWorkerOption ¶
type TrackedDBWorkerOption func(*trackedDBWorker)
TrackedDBWorkerOption is a function that configures a TrackedDBWorker.
func WithClock ¶
func WithClock(clock clock.Clock) TrackedDBWorkerOption
WithClock sets the clock used by the worker.
func WithLogger ¶
func WithLogger(logger logger.Logger) TrackedDBWorkerOption
WithLogger sets the logger used by the worker.
type WorkerConfig ¶
type WorkerConfig struct {
NodeManager NodeManager
Clock clock.Clock
Logger logger.Logger
NewApp NewAppFunc
NewDBReplWorker NewDBReplWorkerFunc
}
WorkerConfig encapsulates the configuration options for the dbaccessor worker.
func (*WorkerConfig) Validate ¶
func (c *WorkerConfig) Validate() error
Validate ensures that the config values are valid.