Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // BuiltinDrivers contains the built in registered drivers // which are available for allocation handling BuiltinDrivers = map[string]Factory{ models.TaskDriverMySQL: NewMySQLDriver, models.TaskDriverKafka: NewKafkaDriver, } // DriverStatsNotImplemented is the error to be returned if a driver doesn't // implement stats. DriverStatsNotImplemented = errors.New("stats not implemented for driver") )
Functions ¶
This section is empty.
Types ¶
type Driver ¶
type Driver interface {
// Start is used to being task execution
Start(ctx *ExecContext, task *models.Task) (DriverHandle, error)
// Drivers must validate their configuration
Validate(task *models.Task) (*models.TaskValidateResponse, error)
}
Driver is used for execution of tasks. This allows Udup to support many pluggable implementations of task drivers.
func NewDriver ¶
func NewDriver(name string, ctx *DriverContext) (Driver, error)
NewDriver is used to instantiate and return a new driver given the name and a logger
func NewKafkaDriver ¶
func NewKafkaDriver(ctx *DriverContext) Driver
func NewMySQLDriver ¶
func NewMySQLDriver(ctx *DriverContext) Driver
NewMySQLDriver is used to create a new mysql driver
type DriverContext ¶
type DriverContext struct {
// contains filtered or unexported fields
}
DriverContext is a means to inject dependencies such as loggers, configs, and node attributes into a Driver without having to change the Driver interface each time we do it. Used in conjection with Factory, above.
func NewDriverContext ¶
func NewDriverContext(taskName, allocID string, config *uconf.ClientConfig, node *models.Node, logger *log.Logger) *DriverContext
NewDriverContext initializes a new DriverContext with the specified fields. This enables other packages to create DriverContexts but keeps the fields private to the driver. If we want to change this later we can gorename all of the fields in DriverContext.
func NewEmptyDriverContext ¶
func NewEmptyDriverContext() *DriverContext
NewEmptyDriverContext returns a DriverContext with all fields set to their zero value.
type DriverHandle ¶
type DriverHandle interface {
// Returns an opaque handle that can be used to re-open the handle
ID() string
// WaitChan is used to return a channel used wait for task completion
WaitCh() chan *models.WaitResult
// Shutdown is used to stop the task
Shutdown() error
// Stats returns aggregated stats of the driver
Stats() (*models.TaskStatistics, error)
}
DriverHandle is an opaque handle into a driver used for task manipulation
type ExecContext ¶
func NewExecContext ¶
func NewExecContext(subject, tp string, mp int) *ExecContext
NewExecContext is used to create a new execution context
type KafkaDriver ¶
type KafkaDriver struct {
DriverContext
}
func (*KafkaDriver) Start ¶
func (kd *KafkaDriver) Start(ctx *ExecContext, task *models.Task) (DriverHandle, error)
func (*KafkaDriver) Validate ¶
func (kd *KafkaDriver) Validate(task *models.Task) (*models.TaskValidateResponse, error)
type MySQLDriver ¶
type MySQLDriver struct {
DriverContext
}
func (*MySQLDriver) Start ¶
func (m *MySQLDriver) Start(ctx *ExecContext, task *models.Task) (DriverHandle, error)
func (*MySQLDriver) Validate ¶
func (m *MySQLDriver) Validate(task *models.Task) (*models.TaskValidateResponse, error)
Validate is used to validate the driver configuration