driver

package
v0.0.0-...-56e5da9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2018 License: MPL-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

type ExecContext struct {
	Subject    string
	Tp         string
	MaxPayload int
}

func NewExecContext

func NewExecContext(subject, tp string, mp int) *ExecContext

NewExecContext is used to create a new execution context

type Factory

type Factory func(*DriverContext) Driver

Factory is used to instantiate a new Driver

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

Directories

Path Synopsis
sql

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL