store

package
v0.0.0-...-16b5886 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrConcurrentUpdate is returned when there is a concurrent update.
	ErrConcurrentUpdate = fmt.Errorf("store: concurrent update")
)

Functions

This section is empty.

Types

type Job

type Job struct {
	gorm.Model

	JobID string `gorm:"uniqueIndex:idx_job_job_id"`

	// Message is the marshaled proto message of v1.Job.
	Message []byte

	State    JobState `gorm:"index:idx_job_state_tenant_id"`
	TenantID string   `gorm:"index:idx_job_state_tenant_id"`

	Version int
}

type JobState

type JobState string

JobState represents the state of a job.

const (
	// JobStatePending represents the pending state.
	JobStatePending JobState = "pending"
	// JobStateRunning represents the running state.
	JobStateRunning JobState = "running"
	// JobStateCompleted represents the completed state.
	JobStateCompleted JobState = "completed"
)

type S

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

S represents the data store.

func New

func New(db *gorm.DB) *S

New creates a new store instance.

func NewTest

func NewTest(t *testing.T) (*S, func())

NewTest returns a new test store.

func (*S) AutoMigrate

func (s *S) AutoMigrate() error

AutoMigrate sets up the auto-migration task of the database.

func (*S) CreateJob

func (s *S) CreateJob(job *Job) error

CreateJob creates a new job.

func (*S) GetJobByJobID

func (s *S) GetJobByJobID(jobID string) (*Job, error)

GetJobByJobID gets a job.

func (*S) ListJobsByTenantID

func (s *S) ListJobsByTenantID(tenantID string) ([]*Job, error)

ListJobsByTenantID finds jobs.

func (*S) ListPendingJobs

func (s *S) ListPendingJobs() ([]*Job, error)

ListPendingJob finds pending jobs.

func (*S) ListPendingJobsByTenantID

func (s *S) ListPendingJobsByTenantID(tenantID string) ([]*Job, error)

ListPendingJobsByTenantID finds pending jobs.

func (*S) UpdateJobState

func (s *S) UpdateJobState(jobID string, currentVersion int, newState JobState) error

UpdateJob updates a job.

Jump to

Keyboard shortcuts

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