database

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JobDBHandler

type JobDBHandler struct {
	// contains filtered or unexported fields
}

JobDBHandler implements JobDBHandlerFunctions and holds the database connection.

func NewJobDBHandler

func NewJobDBHandler(dbConnection *helper.Database, withTableDrop bool) (*JobDBHandler, error)

NewJobDBHandler creates a new instance of JobDBHandler.

func (JobDBHandler) BatchInsertJobs

func (r JobDBHandler) BatchInsertJobs(jobs []*model.Job) error

func (JobDBHandler) CheckTableExistance

func (r JobDBHandler) CheckTableExistance() (bool, error)

CheckTableExistance checks if the 'job' table exists in the database.

func (JobDBHandler) CreateTable

func (r JobDBHandler) CreateTable() error

CreateTable creates the 'job' table in the database if it doesn't already exist. It also creates a trigger for notifying events on the table and all necessary indexes.

func (JobDBHandler) DeleteJob

func (r JobDBHandler) DeleteJob(rid uuid.UUID) error

DeleteJob deletes a job record from the database based on its RID.

func (JobDBHandler) DropTables

func (r JobDBHandler) DropTables() error

DropTables drops the 'job' table from the database.

func (JobDBHandler) InsertJob

func (r JobDBHandler) InsertJob(job *model.Job) (*model.Job, error)

InsertJob inserts a new job record into the database.

func (JobDBHandler) InsertJobTx

func (r JobDBHandler) InsertJobTx(tx *sql.Tx, job *model.Job) (*model.Job, error)

func (JobDBHandler) SelectAllJobs

func (r JobDBHandler) SelectAllJobs(lastID int, entries int) ([]*model.Job, error)

SelectAllJobs retrieves a paginated list of jobs for a specific worker.

func (JobDBHandler) SelectAllJobsBySearch

func (r JobDBHandler) SelectAllJobsBySearch(search string, lastID int, entries int) ([]*model.Job, error)

SelectAllJobsBySearch retrieves a paginated list of jobs for a worker, filtered by search string. It searches across 'rid', 'worker_id', and 'status' fields.

func (JobDBHandler) SelectAllJobsByWorkerRID

func (r JobDBHandler) SelectAllJobsByWorkerRID(workerRid uuid.UUID, lastID int, entries int) ([]*model.Job, error)

SelectAllJobsByWorkerRID retrieves a paginated list of jobs for a specific worker, filtered by worker RID.

func (JobDBHandler) SelectAllJobsFromArchive

func (r JobDBHandler) SelectAllJobsFromArchive(lastID int, entries int) ([]*model.Job, error)

func (JobDBHandler) SelectAllJobsFromArchiveBySearch

func (r JobDBHandler) SelectAllJobsFromArchiveBySearch(search string, lastID int, entries int) ([]*model.Job, error)

func (JobDBHandler) SelectJob

func (r JobDBHandler) SelectJob(rid uuid.UUID) (*model.Job, error)

SelectJob retrieves a single job record from the database based on its RID.

func (JobDBHandler) SelectJobFromArchive

func (r JobDBHandler) SelectJobFromArchive(rid uuid.UUID) (*model.Job, error)

Job Archive

func (JobDBHandler) UpdateJobFinal

func (r JobDBHandler) UpdateJobFinal(job *model.Job) (*model.Job, error)

UpdateJobFinal updates an existing job record in the database to state 'FAILED' or 'SUCCEEDED'.

func (JobDBHandler) UpdateJobsInitial

func (r JobDBHandler) UpdateJobsInitial(worker *model.Worker) ([]*model.Job, error)

UpdateJobsInitial updates an existing queued non locked job record in the database. Checks if the job is in 'QUEUED' or 'FAILED' status and if the worker can handle the task.

type JobDBHandlerFunctions

type JobDBHandlerFunctions interface {
	CheckTableExistance() (bool, error)
	CreateTable() error
	DropTables() error
	InsertJob(job *model.Job) (*model.Job, error)
	InsertJobTx(tx *sql.Tx, job *model.Job) (*model.Job, error)
	BatchInsertJobs(jobs []*model.Job) error
	UpdateJobsInitial(worker *model.Worker) ([]*model.Job, error)
	UpdateJobFinal(job *model.Job) (*model.Job, error)
	DeleteJob(rid uuid.UUID) error
	SelectJob(rid uuid.UUID) (*model.Job, error)
	SelectAllJobs(lastID int, entries int) ([]*model.Job, error)
	SelectAllJobsByWorkerRID(workerRid uuid.UUID, lastID int, entries int) ([]*model.Job, error)
	SelectAllJobsBySearch(search string, lastID int, entries int) ([]*model.Job, error)
	// Job Archive
	SelectJobFromArchive(rid uuid.UUID) (*model.Job, error)
	SelectAllJobsFromArchive(lastID int, entries int) ([]*model.Job, error)
	SelectAllJobsFromArchiveBySearch(search string, lastID int, entries int) ([]*model.Job, error)
}

JobDBHandlerFunctions defines the interface for Job database operations.

type QueuerListener

type QueuerListener struct {
	Listener *pq.Listener
	Channel  string
}

func NewQueuerDBListener

func NewQueuerDBListener(dbConfig *helper.DatabaseConfiguration, channel string) (*QueuerListener, error)

NewQueuerDBListener creates a new QueuerListener instance.

func (*QueuerListener) Listen

func (l *QueuerListener) Listen(ctx context.Context, cancel context.CancelFunc, notifyFunction func(data string))

Listen listens for events on the specified channel and processes them.

type WorkerDBHandler

type WorkerDBHandler struct {
	// contains filtered or unexported fields
}

WorkerDBHandler implements WorkerDBHandlerFunctions and holds the database connection.

func NewWorkerDBHandler

func NewWorkerDBHandler(dbConnection *helper.Database, withTableDrop bool) (*WorkerDBHandler, error)

NewWorkerDBHandler creates a new instance of WorkerDBHandler.

func (WorkerDBHandler) CheckTableExistance

func (r WorkerDBHandler) CheckTableExistance() (bool, error)

CheckTableExistance checks if the 'worker' table exists in the database.

func (WorkerDBHandler) CreateTable

func (r WorkerDBHandler) CreateTable() error

CreateTable creates the 'worker' table in the database if it doesn't already exist.

func (WorkerDBHandler) DeleteWorker

func (r WorkerDBHandler) DeleteWorker(rid uuid.UUID) error

DeleteWorker deletes a worker record from the database based on its RID.

func (WorkerDBHandler) DropTable

func (r WorkerDBHandler) DropTable() error

DropTable drops the 'worker' table from the database.

func (WorkerDBHandler) InsertWorker

func (r WorkerDBHandler) InsertWorker(worker *model.Worker) (*model.Worker, error)

InsertWorker inserts a new worker record into the database.

func (WorkerDBHandler) SelectAllWorkers

func (r WorkerDBHandler) SelectAllWorkers(lastID int, entries int) ([]*model.Worker, error)

SelectAllWorkers retrieves a paginated list of all workers.

func (WorkerDBHandler) SelectAllWorkersBySearch

func (r WorkerDBHandler) SelectAllWorkersBySearch(search string, lastID int, entries int) ([]*model.Worker, error)

SelectAllWorkersBySearch retrieves a paginated list of workers, filtered by search string. It searches across 'queue_name', 'name', and 'status' fields.

func (WorkerDBHandler) SelectWorker

func (r WorkerDBHandler) SelectWorker(rid uuid.UUID) (*model.Worker, error)

SelectWorker retrieves a single worker record from the database based on its RID.

func (WorkerDBHandler) UpdateWorker

func (r WorkerDBHandler) UpdateWorker(worker *model.Worker) (*model.Worker, error)

UpdateWorker updates an existing worker record in the database based on its RID.

type WorkerDBHandlerFunctions

type WorkerDBHandlerFunctions interface {
	CheckTableExistance() (bool, error)
	CreateTable() error
	DropTable() error
	InsertWorker(worker *model.Worker) (*model.Worker, error)
	UpdateWorker(worker *model.Worker) (*model.Worker, error)
	DeleteWorker(rid uuid.UUID) error
	SelectWorker(rid uuid.UUID) (*model.Worker, error)
	SelectAllWorkers(lastID int, entries int) ([]*model.Worker, error)
	SelectAllWorkersBySearch(search string, lastID int, entries int) ([]*model.Worker, error)
}

WorkerDBHandlerFunctions defines the interface for Worker database operations.

Jump to

Keyboard shortcuts

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