database

package
v0.0.0-...-d93108c Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTask

func AddTask(db *sql.DB, task globalstructs.Task, verbose, debug bool, wg *sync.WaitGroup) error

AddTask adds a task to the database

func AddWorker

func AddWorker(db *sql.DB, worker *globalstructs.Worker, verbose, debug bool, wg *sync.WaitGroup) error

AddWorker adds a worker to the database.

func AddWorkerDownCount

func AddWorkerDownCount(db *sql.DB, worker *globalstructs.Worker, verbose, debug bool, wg *sync.WaitGroup) error

AddWorkerCount add 1 to worker downCount

func AddWorkerIddleThreads1

func AddWorkerIddleThreads1(db *sql.DB, worker string, verbose, debug bool, wg *sync.WaitGroup) error

SetWorkerworkingToString sets the status of a worker to the specified working value using the worker's name.

func ConnectDB

func ConnectDB(username, password, host, port, database string, verbose, debug bool) (*sql.DB, error)

ConnectDB creates a new Manager instance and initializes the database connection. It takes the username, password, host, port, and database name as input. It returns a pointer to the sql.DB object and an error if the connection fails.

func GetDeletedCount

func GetDeletedCount(db *sql.DB, verbose, debug bool) (int, error)

func GetDoneCount

func GetDoneCount(db *sql.DB, verbose, debug bool) (int, error)

func GetDownCount

func GetDownCount(db *sql.DB, verbose, debug bool) (int, error)

func GetFailedCount

func GetFailedCount(db *sql.DB, verbose, debug bool) (int, error)

func GetPendingCount

func GetPendingCount(db *sql.DB, verbose, debug bool) (int, error)

func GetRunningCount

func GetRunningCount(db *sql.DB, verbose, debug bool) (int, error)

func GetTask

func GetTask(db *sql.DB, id string, verbose, debug bool) (globalstructs.Task, error)

GetTask gets task filtered by id

func GetTaskExecutedAt

func GetTaskExecutedAt(db *sql.DB, id string, verbose, debug bool) (string, error)

GetTaskExecutedAt

func GetTaskWorker

func GetTaskWorker(db *sql.DB, id string, verbose, debug bool) (string, error)

GetTaskWorker gets task workerName from an ID This is the worker executing the task

func GetTasks

func GetTasks(r *http.Request, db *sql.DB, verbose, debug bool) ([]globalstructs.Task, error)

GetTasks gets tasks with URL params as filter.

func GetTasksPending

func GetTasksPending(limit int, db *sql.DB, verbose, debug bool) ([]globalstructs.Task, error)

GetTasksPending gets only tasks with status pending

func GetTasksSQL

func GetTasksSQL(sql string, db *sql.DB, verbose, debug bool) ([]globalstructs.Task, error)

GetTasksSQL gets tasks by passing the SQL query in sql param

func GetUpCount

func GetUpCount(db *sql.DB, verbose, debug bool) (int, error)

func GetWorker

func GetWorker(db *sql.DB, name string, verbose, debug bool) (globalstructs.Worker, error)

GetWorker retrieves a worker from the database by its name.

func GetWorkerDownCount

func GetWorkerDownCount(db *sql.DB, worker *globalstructs.Worker, verbose, debug bool) (int, error)

GetWorkerCount get workers downCount by name (used to downCount until 3 to set down)

func GetWorkerIddle

func GetWorkerIddle(db *sql.DB, verbose, debug bool) ([]globalstructs.Worker, error)

GetWorkerIddle retrieves all workers that are iddle.

func GetWorkerSQL

func GetWorkerSQL(sql string, db *sql.DB, verbose, debug bool) ([]globalstructs.Worker, error)

GetWorkerSQL retrieves workers information based on a SQL statement.

func GetWorkerUP

func GetWorkerUP(db *sql.DB, verbose, debug bool) ([]globalstructs.Worker, error)

GetWorkerUP retrieves all workers that are up.

func GetWorkers

func GetWorkers(db *sql.DB, verbose, debug bool) ([]globalstructs.Worker, error)

GetWorkers retrieves all workers from the database.

func RmTask

func RmTask(db *sql.DB, id string, verbose, debug bool, wg *sync.WaitGroup) error

RmTask deletes a task from the database.

func RmWorkerName

func RmWorkerName(db *sql.DB, name string, verbose, debug bool, wg *sync.WaitGroup) error

RmWorkerName deletes a worker by its name.

func SetIddleThreadsTo

func SetIddleThreadsTo(IddleThreads int, db *sql.DB, worker string, verbose, debug bool, wg *sync.WaitGroup) error

SetWorkerworkingToString sets the status of a worker to the specified working value using the worker's name.

func SetTaskExecutedAt

func SetTaskExecutedAt(executedAt string, db *sql.DB, id string, verbose, debug bool, wg *sync.WaitGroup) error

SetTaskExecutedAt saves current time as executedAt

func SetTaskExecutedAtNow

func SetTaskExecutedAtNow(db *sql.DB, id string, verbose, debug bool, wg *sync.WaitGroup) error

SetTaskExecutedAt saves current time as executedAt

func SetTaskStatus

func SetTaskStatus(db *sql.DB, id, status string, verbose, debug bool, wg *sync.WaitGroup) error

SetTaskStatus saves the status of the task in the database

func SetTaskStatusIfPending

func SetTaskStatusIfPending(db *sql.DB, id, status string, verbose, debug bool, wg *sync.WaitGroup) error

SetTaskStatusIfPending saves the status of the task in the database if current is pending

func SetTaskWorkerName

func SetTaskWorkerName(db *sql.DB, id, workerName string, verbose, debug bool, wg *sync.WaitGroup) error

SetTaskWorkerName saves the worker name of the task in the database

func SetTasksStatusIfRunning

func SetTasksStatusIfRunning(db *sql.DB, status string, verbose, debug bool, wg *sync.WaitGroup) error

SetTaskStatusIfPending saves the status of the task in the database if current is pending

func SetTasksWorkerEmpty

func SetTasksWorkerEmpty(db *sql.DB, workerName string, verbose, debug bool, wg *sync.WaitGroup) error

SetTasksWorkerEmpty remove the worker name of the task in the database

func SetTasksWorkerFailed

func SetTasksWorkerFailed(db *sql.DB, workerName string, verbose, debug bool, wg *sync.WaitGroup) error

SetTasksWorkerFailed set to failed all task running worker workerName

func SetTasksWorkerInvalid

func SetTasksWorkerInvalid(db *sql.DB, workerName string, verbose, debug bool, wg *sync.WaitGroup) error

SetTasksWorkerInvalid set to invalid all task running worker workerName

func SetTasksWorkerPending

func SetTasksWorkerPending(db *sql.DB, workerName string, verbose, debug bool, wg *sync.WaitGroup) error

SetTasksWorkerPending set all task of worker to pending because failed

func SetWorkerDownCount

func SetWorkerDownCount(count int, db *sql.DB, worker *globalstructs.Worker, verbose, debug bool, wg *sync.WaitGroup) error

SetWorkerCount set worker downCount to downCount int

func SetWorkerUPto

func SetWorkerUPto(up bool, db *sql.DB, worker *globalstructs.Worker, verbose, debug bool, wg *sync.WaitGroup) error

SetWorkerUPto sets the status of a worker to the specified value.

func SubtractWorkerIddleThreads1

func SubtractWorkerIddleThreads1(db *sql.DB, worker string, verbose, debug bool, wg *sync.WaitGroup) error

SubtractWorkerIddleThreads1

func UpdateTask

func UpdateTask(db *sql.DB, task globalstructs.Task, verbose, debug bool, wg *sync.WaitGroup) error

UpdateTask updates all fields of a task in the database.

func UpdateWorker

func UpdateWorker(db *sql.DB, worker *globalstructs.Worker, verbose, debug bool, wg *sync.WaitGroup) error

UpdateWorker updates the information of a worker in the database.

Types

This section is empty.

Jump to

Keyboard shortcuts

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