Documentation
¶
Index ¶
Constants ¶
const (
SQLErrorSessionNotFound = "SL001"
)
SQL errors
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DBFinder ¶
DBFinder will return an Database implementation This will be called every loop in case the DB moves
type Database ¶
type Database interface { StartSession(ctx context.Context) (int64, glitch.DataError) EndSession(ctx context.Context, sessionID int64) glitch.DataError BumpSession(ctx context.Context, sessionID int64) glitch.DataError GetWork(ctx context.Context, sessionID int64, tasksPerSession int64, scanTask ScanTask) ([]Task, glitch.DataError) FinishTasks(ctx context.Context, taskIDs []string) glitch.DataError }
Database can make the PG calls necessary to use a session locked runner
type Logger ¶
type Logger interface { Printf(format string, a ...interface{}) Errorf(format string, a ...interface{}) }
Logger allows you to control how logging happens
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner will loop and run tasks assigned to it
func NewRunner ¶
func NewRunner(dbFinder DBFinder, scanTask ScanTask, tasker Tasker, loopTick time.Duration, tasksPerSession int64, logger Logger, name string, client metrics.Client) *Runner
NewRunner will create a new Runner to handle a type of task dbFinder can get an instance of the Database interface on demand scanTask can read from a sql.row into a Task tasker can complete Tasks looptick defines how often to check for tasks to complete client is a go-metrics-client that will also start spans for us logger is optional and will log errors if provided
type ScanTask ¶
ScanTask can scan the data from Get work and store it in a struct. That struct should be returned and will be added to the GetWork array.
type Scanner ¶
type Scanner interface {
Scan(dest ...interface{}) error
}
Scanner is an interface for the database/sql Scan function. sql.Rows and sql.Row implement this
type Task ¶
type Task interface {
GetID() string
}
Task is an interface that can GetID - This is meant to be implemented as a struct that holds all task info that The Tasker needs to do the work associated with the task.