repository

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: AGPL-3.0 Imports: 6 Imported by: ? 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

This section is empty.

Functions

This section is empty.

Types

type AcquireJobLockInDBParams

type AcquireJobLockInDBParams struct {
	TenantID    string    `json:"tenant_id"`
	Lock        string    `json:"lock"`
	JobName     string    `json:"job_name"`
	Now         time.Time `json:"now"`
	NextRunTime time.Time `json:"next_run_time"`
	InstanceID  string    `json:"instance_id"`
}

type CountJobAuditLogsByJobNameParams

type CountJobAuditLogsByJobNameParams struct {
	JobName  string `json:"job_name"`
	TenantID string `json:"tenant_id"`
}

type CountRegisteredJobsParams

type CountRegisteredJobsParams struct {
	TenantID   string      `json:"tenant_id"`
	SearchTerm interface{} `json:"search_term"`
}

type CreateJobAuditLogParams

type CreateJobAuditLogParams struct {
	UserID        string           `json:"user_id"`
	AppID         string           `json:"app_id"`
	RequestID     string           `json:"request_id"`
	JobName       string           `json:"job_name"`
	ScheduledTime pgtype.Timestamp `json:"scheduled_time"`
	StartTime     pgtype.Timestamp `json:"start_time"`
	EndTime       pgtype.Timestamp `json:"end_time"`
	Status        string           `json:"status"`
	Output        pgtype.Text      `json:"output"`
	Error         pgtype.Text      `json:"error"`
	TenantID      string           `json:"tenant_id"`
}

type CreateJobParams

type CreateJobParams struct {
	Lock              string             `json:"lock"`
	JobName           string             `json:"job_name"`
	LastExecutionTime pgtype.Timestamptz `json:"last_execution_time"`
	NextExecutionTime pgtype.Timestamptz `json:"next_execution_time"`
	LockedBy          pgtype.Text        `json:"locked_by"`
	LockedAt          pgtype.Timestamptz `json:"locked_at"`
	TenantID          string             `json:"tenant_id"`
}

type CronJob

type CronJob struct {
	ID                uuid.UUID          `json:"id"`
	Lock              string             `json:"lock"`
	JobName           string             `json:"job_name"`
	Status            string             `json:"status"`
	LastExecutionTime pgtype.Timestamptz `json:"last_execution_time"`
	NextExecutionTime pgtype.Timestamptz `json:"next_execution_time"`
	LockedBy          pgtype.Text        `json:"locked_by"`
	LockedAt          pgtype.Timestamptz `json:"locked_at"`
	TenantID          string             `json:"tenant_id"`
	CreatedAt         time.Time          `json:"created_at"`
	UpdatedAt         time.Time          `json:"updated_at"`
}

type CronJobAuditLog

type CronJobAuditLog struct {
	ID            uuid.UUID        `json:"id"`
	AppID         string           `json:"app_id"`
	RequestID     string           `json:"request_id"`
	JobName       string           `json:"job_name"`
	ScheduledTime pgtype.Timestamp `json:"scheduled_time"`
	StartTime     pgtype.Timestamp `json:"start_time"`
	EndTime       pgtype.Timestamp `json:"end_time"`
	Status        string           `json:"status"`
	Output        pgtype.Text      `json:"output"`
	Error         pgtype.Text      `json:"error"`
	UserID        string           `json:"user_id"`
	TenantID      string           `json:"tenant_id"`
	CreatedAt     pgtype.Timestamp `json:"created_at"`
	UpdatedAt     pgtype.Timestamp `json:"updated_at"`
}

type CronRegisteredJob

type CronRegisteredJob struct {
	ID                uuid.UUID   `json:"id"`
	JobName           string      `json:"job_name"`
	Schedule          string      `json:"schedule"`
	IsLongRunning     bool        `json:"is_long_running"`
	IsEnabled         bool        `json:"is_enabled"`
	LastRegisteredAt  time.Time   `json:"last_registered_at"`
	InstanceID        string      `json:"instance_id"`
	TenantID          string      `json:"tenant_id"`
	CreatedAt         time.Time   `json:"created_at"`
	UpdatedAt         time.Time   `json:"updated_at"`
	RegistrationError pgtype.Text `json:"registration_error"`
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type DeleteJobAuditLogParams

type DeleteJobAuditLogParams struct {
	ID       uuid.UUID `json:"id"`
	TenantID string    `json:"tenant_id"`
}

type DeleteJobParams

type DeleteJobParams struct {
	ID       uuid.UUID `json:"id"`
	TenantID string    `json:"tenant_id"`
}

type DeleteRegisteredJobParams

type DeleteRegisteredJobParams struct {
	JobName  string `json:"job_name"`
	TenantID string `json:"tenant_id"`
}

type ForceUnlockJobParams

type ForceUnlockJobParams struct {
	JobID    uuid.UUID `json:"job_id"`
	TenantID string    `json:"tenant_id"`
}

type GetJobAuditLogByIDParams

type GetJobAuditLogByIDParams struct {
	ID       uuid.UUID `json:"id"`
	TenantID string    `json:"tenant_id"`
}

type GetJobByIDParams

type GetJobByIDParams struct {
	ID       uuid.UUID `json:"id"`
	TenantID string    `json:"tenant_id"`
}

type GetRegisteredJobByIDParams

type GetRegisteredJobByIDParams struct {
	ID       uuid.UUID `json:"id"`
	TenantID string    `json:"tenant_id"`
}

type GetRegisteredJobEnabledParams

type GetRegisteredJobEnabledParams struct {
	TenantID string `json:"tenant_id"`
	JobName  string `json:"job_name"`
}

type GetStaleJobsRow

type GetStaleJobsRow struct {
	ID       uuid.UUID          `json:"id"`
	Lock     string             `json:"lock"`
	JobName  string             `json:"job_name"`
	TenantID string             `json:"tenant_id"`
	LockedBy pgtype.Text        `json:"locked_by"`
	LockedAt pgtype.Timestamptz `json:"locked_at"`
	Status   string             `json:"status"`
}

type IsJobLockedParams

type IsJobLockedParams struct {
	TenantID string `json:"tenant_id"`
	Lock     string `json:"lock"`
}

type IsJobLockedRow

type IsJobLockedRow struct {
	ID       uuid.UUID          `json:"id"`
	IsLocked bool               `json:"is_locked"`
	LockedBy pgtype.Text        `json:"locked_by"`
	LockedAt pgtype.Timestamptz `json:"locked_at"`
}

type ListJobAuditLogsByJobNameParams

type ListJobAuditLogsByJobNameParams struct {
	JobName  string `json:"job_name"`
	TenantID string `json:"tenant_id"`
	SortBy   string `json:"sort_by"`
	Order    string `json:"order"`
	Offset   int32  `json:"offset"`
	Limit    int32  `json:"limit"`
}

type ListJobAuditLogsParams

type ListJobAuditLogsParams struct {
	Limit    int32       `json:"limit"`
	Offset   int32       `json:"offset"`
	TenantID string      `json:"tenant_id"`
	Like     interface{} `json:"like"`
	SortBy   string      `json:"sortBy"`
	Order    string      `json:"order"`
}

type ListJobsParams

type ListJobsParams struct {
	Limit    int32       `json:"limit"`
	Offset   int32       `json:"offset"`
	TenantID string      `json:"tenant_id"`
	Like     interface{} `json:"like"`
	SortBy   string      `json:"sortBy"`
	Order    string      `json:"order"`
}

type ListRegisteredJobsParams

type ListRegisteredJobsParams struct {
	TenantID   string      `json:"tenant_id"`
	SearchTerm interface{} `json:"search_term"`
	SortBy     string      `json:"sort_by"`
	Order      string      `json:"order"`
	Offset     int32       `json:"offset"`
	Limit      int32       `json:"limit"`
}

type ListRegisteredJobsRow

type ListRegisteredJobsRow struct {
	ID                uuid.UUID   `json:"id"`
	JobName           string      `json:"job_name"`
	Schedule          string      `json:"schedule"`
	IsLongRunning     bool        `json:"is_long_running"`
	IsEnabled         bool        `json:"is_enabled"`
	LastRegisteredAt  time.Time   `json:"last_registered_at"`
	InstanceID        string      `json:"instance_id"`
	TenantID          string      `json:"tenant_id"`
	CreatedAt         time.Time   `json:"created_at"`
	UpdatedAt         time.Time   `json:"updated_at"`
	RegistrationError pgtype.Text `json:"registration_error"`
	ExecutionCount    int64       `json:"execution_count"`
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) AcquireJobLockInDB

func (q *Queries) AcquireJobLockInDB(ctx context.Context, arg AcquireJobLockInDBParams) (uuid.UUID, error)

func (*Queries) CleanupOldTasks

func (q *Queries) CleanupOldTasks(ctx context.Context, tenantID string) (pgconn.CommandTag, error)

func (*Queries) CleanupStaleLocks

func (q *Queries) CleanupStaleLocks(ctx context.Context, tenantID string) (pgconn.CommandTag, error)

NEW: Clean up stale locks from crashed instances

func (*Queries) CleanupStaleRegisteredJobs

func (q *Queries) CleanupStaleRegisteredJobs(ctx context.Context, tenantID string) (pgconn.CommandTag, error)

A disabled row is kept: deleting it would forget the admin's decision, and the next registration would recreate the job enabled.

func (*Queries) CountJobAuditLogsByJobName

func (q *Queries) CountJobAuditLogsByJobName(ctx context.Context, arg CountJobAuditLogsByJobNameParams) (int64, error)

func (*Queries) CountRegisteredJobs

func (q *Queries) CountRegisteredJobs(ctx context.Context, arg CountRegisteredJobsParams) (int64, error)

func (*Queries) CreateJob

func (q *Queries) CreateJob(ctx context.Context, arg CreateJobParams) (CronJob, error)

func (*Queries) CreateJobAuditLog

func (q *Queries) CreateJobAuditLog(ctx context.Context, arg CreateJobAuditLogParams) (CronJobAuditLog, error)

func (*Queries) DeleteJob

func (q *Queries) DeleteJob(ctx context.Context, arg DeleteJobParams) (uuid.UUID, error)

func (*Queries) DeleteJobAuditLog

func (q *Queries) DeleteJobAuditLog(ctx context.Context, arg DeleteJobAuditLogParams) (uuid.UUID, error)

func (*Queries) DeleteRegisteredJob

func (q *Queries) DeleteRegisteredJob(ctx context.Context, arg DeleteRegisteredJobParams) error

func (*Queries) ForceUnlockJob

func (q *Queries) ForceUnlockJob(ctx context.Context, arg ForceUnlockJobParams) error

NEW: Force unlock a specific job (for admin operations)

func (*Queries) GetJobAuditLogByID

func (q *Queries) GetJobAuditLogByID(ctx context.Context, arg GetJobAuditLogByIDParams) (CronJobAuditLog, error)

func (*Queries) GetJobByID

func (q *Queries) GetJobByID(ctx context.Context, arg GetJobByIDParams) (CronJob, error)

func (*Queries) GetRegisteredJobByID

func (q *Queries) GetRegisteredJobByID(ctx context.Context, arg GetRegisteredJobByIDParams) (CronRegisteredJob, error)

func (*Queries) GetRegisteredJobEnabled

func (q *Queries) GetRegisteredJobEnabled(ctx context.Context, arg GetRegisteredJobEnabledParams) (bool, error)

func (*Queries) GetStaleJobs

func (q *Queries) GetStaleJobs(ctx context.Context, tenantID string) ([]GetStaleJobsRow, error)

NEW: Get jobs that are potentially stuck

func (*Queries) IsJobLocked

func (q *Queries) IsJobLocked(ctx context.Context, arg IsJobLockedParams) (IsJobLockedRow, error)

NEW: Check if a job is currently locked by any instance

func (*Queries) ListJobAuditLogs

func (q *Queries) ListJobAuditLogs(ctx context.Context, arg ListJobAuditLogsParams) ([]CronJobAuditLog, error)

func (*Queries) ListJobAuditLogsByJobName

func (q *Queries) ListJobAuditLogsByJobName(ctx context.Context, arg ListJobAuditLogsByJobNameParams) ([]CronJobAuditLog, error)

func (*Queries) ListJobs

func (q *Queries) ListJobs(ctx context.Context, arg ListJobsParams) ([]CronJob, error)

func (*Queries) ListRegisteredJobs

func (q *Queries) ListRegisteredJobs(ctx context.Context, arg ListRegisteredJobsParams) ([]ListRegisteredJobsRow, error)

func (*Queries) ReleaseTaskLock

func (q *Queries) ReleaseTaskLock(ctx context.Context, arg ReleaseTaskLockParams) error

func (*Queries) UpdateJob

func (q *Queries) UpdateJob(ctx context.Context, arg UpdateJobParams) (CronJob, error)

func (*Queries) UpdateJobAuditLog

func (q *Queries) UpdateJobAuditLog(ctx context.Context, arg UpdateJobAuditLogParams) (CronJobAuditLog, error)

func (*Queries) UpdateJobHeartbeat

func (q *Queries) UpdateJobHeartbeat(ctx context.Context, arg UpdateJobHeartbeatParams) error

NEW: Heartbeat update for long-running jobs

func (*Queries) UpdateJobStatusToCompleted

func (q *Queries) UpdateJobStatusToCompleted(ctx context.Context, arg UpdateJobStatusToCompletedParams) (pgconn.CommandTag, error)

func (*Queries) UpdateJobStatusToFailed

func (q *Queries) UpdateJobStatusToFailed(ctx context.Context, arg UpdateJobStatusToFailedParams) (pgconn.CommandTag, error)

The locked_by predicate fences the write: a run that overran the staleness window has already lost the lease to another instance, and must not stamp its outcome over the run that superseded it. Zero rows affected means exactly that.

func (*Queries) UpdateRegisteredJobEnabled

func (q *Queries) UpdateRegisteredJobEnabled(ctx context.Context, arg UpdateRegisteredJobEnabledParams) (pgconn.CommandTag, error)

func (*Queries) UpsertRegisteredJob

func (q *Queries) UpsertRegisteredJob(ctx context.Context, arg UpsertRegisteredJobParams) (CronRegisteredJob, error)

is_enabled only seeds a NEW row: on conflict it is left alone, because it is the admin's decision and every restart re-registers every job.

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type ReleaseTaskLockParams

type ReleaseTaskLockParams struct {
	ID       uuid.UUID `json:"id"`
	TenantID string    `json:"tenant_id"`
}

type UpdateJobAuditLogParams

type UpdateJobAuditLogParams struct {
	ID       uuid.UUID        `json:"id"`
	EndTime  pgtype.Timestamp `json:"end_time"`
	Status   string           `json:"status"`
	Output   pgtype.Text      `json:"output"`
	Error    pgtype.Text      `json:"error"`
	TenantID string           `json:"tenant_id"`
}

type UpdateJobHeartbeatParams

type UpdateJobHeartbeatParams struct {
	JobID      uuid.UUID `json:"job_id"`
	InstanceID string    `json:"instance_id"`
}

type UpdateJobParams

type UpdateJobParams struct {
	ID                uuid.UUID          `json:"id"`
	Lock              string             `json:"lock"`
	JobName           string             `json:"job_name"`
	Status            string             `json:"status"`
	LastExecutionTime pgtype.Timestamptz `json:"last_execution_time"`
	NextExecutionTime pgtype.Timestamptz `json:"next_execution_time"`
	LockedBy          pgtype.Text        `json:"locked_by"`
	LockedAt          pgtype.Timestamptz `json:"locked_at"`
	TenantID          string             `json:"tenant_id"`
}

type UpdateJobStatusToCompletedParams

type UpdateJobStatusToCompletedParams struct {
	JobID      uuid.UUID `json:"job_id"`
	InstanceID string    `json:"instance_id"`
}

type UpdateJobStatusToFailedParams

type UpdateJobStatusToFailedParams struct {
	JobID      uuid.UUID `json:"job_id"`
	InstanceID string    `json:"instance_id"`
}

type UpdateRegisteredJobEnabledParams

type UpdateRegisteredJobEnabledParams struct {
	IsEnabled bool      `json:"is_enabled"`
	ID        uuid.UUID `json:"id"`
	TenantID  string    `json:"tenant_id"`
}

type UpsertRegisteredJobParams

type UpsertRegisteredJobParams struct {
	JobName           string      `json:"job_name"`
	Schedule          string      `json:"schedule"`
	IsLongRunning     bool        `json:"is_long_running"`
	IsEnabled         bool        `json:"is_enabled"`
	InstanceID        string      `json:"instance_id"`
	TenantID          string      `json:"tenant_id"`
	RegistrationError pgtype.Text `json:"registration_error"`
}

Jump to

Keyboard shortcuts

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