model

package
v0.0.0-...-fe29fb6 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

DB gorm DB

Functions

func ConnectDataBase

func ConnectDataBase(param []string) (*pkg.CduleConfig, error)

ConnectDataBase to create a database connection

func Migrate

func Migrate(db *gorm.DB)

Migrate database schema

Types

type CduleRepository

type CduleRepository interface {
	CreateWorker(worker *Worker) (*Worker, error)
	UpdateWorker(worker *Worker) (*Worker, error)
	GetWorker(workerID string) (*Worker, error)
	GetWorkers() ([]Worker, error)
	GetAliveWorkers() ([]Worker, error)
	DeleteWorker(workerID string) (*Worker, error)

	CreateJob(job *Job) (*Job, error)
	UpdateJob(job *Job) (*Job, error)
	GetJob(jobID int64) (*Job, error)
	GetJobByName(name string) (*Job, error)
	DeleteJob(jobID int64) (*Job, error)

	CreateJobHistory(jobHistory *JobHistory) (*JobHistory, error)
	UpdateJobHistory(jobHistory *JobHistory) (*JobHistory, error)
	GetJobHistory(jobID int64) ([]JobHistory, error)
	GetJobHistoryWithLimit(jobID int64, limit int) ([]JobHistory, error)
	GetJobHistoryForSchedule(scheduleID int64) (*JobHistory, error)
	DeleteJobHistory(jobID int64) ([]JobHistory, error)

	CreateSchedule(schedule *Schedule) (*Schedule, error)
	UpdateSchedule(schedule *Schedule) (*Schedule, error)
	GetSchedule(scheduleID int64) (*Schedule, error)
	GetScheduleBetween(scheduleStart, scheduleEnd int64, workerID string) ([]Schedule, error)
	GetSchedulesForJob(jobID int64) ([]Schedule, error)
	GetSchedulesForWorker(workerID string) ([]Schedule, error)
	DeleteScheduleForJob(jobID int64) ([]Schedule, error)
	DeleteScheduleForWorker(workerID string) ([]Schedule, error)
}

CduleRepository cdule repository interface

func NewCduleRepository

func NewCduleRepository(db *gorm.DB) CduleRepository

NewCduleRepository cdule repository

type Job

type Job struct {
	Model
	JobName        string `gorm:"index",json:"job_name"`
	GroupName      string `json:"group_name"`
	CronExpression string `json:"cron"`
	Expired        bool   `json:"expired"`
	JobData        string `json:"job_data"`
}

Job struct

type JobHistory

type JobHistory struct {
	Model
	JobID       int64          `json:"job_id"`
	ExecutionID int64          `json:"execution_id"`
	DeletedAt   gorm.DeletedAt `gorm:"index"`
	Status      JobStatus      `json:"status"`
	WorkerID    string         `json:"worker_id"`
	RetryCount  int            `json:"retry_count"`
}

JobHistory struct

type JobStatus

type JobStatus string

JobStatus for job status

const (
	// JobStatusNew status NEW
	JobStatusNew JobStatus = "NEW"
	// JobStatusInProgress status IN_PROGRESS
	JobStatusInProgress JobStatus = "IN_PROGRESS"
	// JobStatusCompleted status COMPLETED
	JobStatusCompleted JobStatus = "COMPLETED"
	// JobStatusFailed status FAILED
	JobStatusFailed JobStatus = "FAILED"
)

type Model

type Model struct {
	ID        int64 `gorm:"primarykey"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"column:model_deleted_at; index"`
}

Model common model

type Repositories

type Repositories struct {
	CduleRepository CduleRepository
	DB              *gorm.DB
}

Repositories struct

var CduleRepos *Repositories

CduleRepos repositories

type Schedule

type Schedule struct {
	ExecutionID int64 `gorm:"primaryKey",json:"execution_id"`
	JobID       int64 `gorm:"primaryKey",json:"job_id"`
	Job         Job   `gorm:"foreignKey:JobID;references:ID;constraint:OnDelete:CASCADE"`
	CreatedAt   time.Time
	UpdatedAt   time.Time
	DeletedAt   gorm.DeletedAt `gorm:"index"`
	WorkerID    string         `json:"worker_id"`
	JobData     string         `json:"job_data"`
}

Schedule used by Execution Routine to execute a scheduled job in the evert one minute duration

type Worker

type Worker struct {
	WorkerID  string `gorm:"primaryKey",json:"worker_id"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

Worker Node health check via the heartbeat

Jump to

Keyboard shortcuts

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