service

package
v0.0.0-...-2f4d8a3 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrJobHistoryNotFound = errors.New("JobHistory not found")
View Source
var ErrJobStatusAlreadyExists = errors.New("JobStatus already exists")
View Source
var ErrJobStatusNotFound = errors.New("JobStatus not found")

Functions

This section is empty.

Types

type Job

type Job interface {
	GetName() domain.JobName
	GetJobParameter() string
	GetTimeout() time.Duration
	IsAllowedConcurrentExecution() bool
	Run(ctx context.Context) error
}

func NewJob

func NewJob(name domain.JobName, timeout time.Duration, allowedConcurrentExecution bool, fn JobFunc) (Job, error)

type JobFunc

type JobFunc func(context.Context) error

type JobHistory

type JobHistory interface {
}

func NewJobHistory

func NewJobHistory() (JobHistory, error)

type JobHistoryAddParameter

type JobHistoryAddParameter interface {
	GetJobStatusID() domain.JobStatusID
	GetJobName() domain.JobName
	GetJobParamter() string
	GetStatus() string
}

func NewJobHistoryAddParameter

func NewJobHistoryAddParameter(jobStatusID domain.JobStatusID, jobName domain.JobName, jobParameter string, status string) (JobHistoryAddParameter, error)

type JobHistoryRepository

type JobHistoryRepository interface {
	AddJobHistory(ctx context.Context, param JobHistoryAddParameter) error
	FindJobHistoryByJobName(ctx context.Context, jobName domain.JobName) (JobHistory, error)
}

type JobService

type JobService interface {
	StartJob(ctx context.Context, job Job) error
	CleanOldJobs(ctx context.Context) error
}

func NewJobService

func NewJobService(ctx context.Context, transaction Transaction) (JobService, error)

type JobStatus

type JobStatus interface {
	GetJobStatusID() domain.JobStatusID
	GetJobName() domain.JobName
	GetJobParameter() string
}

func NewJobStatus

func NewJobStatus(jobStatusID domain.JobStatusID, jobName domain.JobName, jobParameter string, expirationDatetime *time.Time, createdAt time.Time) (JobStatus, error)

type JobStatusRepository

type JobStatusRepository interface {
	AddJobStatus(ctx context.Context, job Job) (domain.JobStatusID, error)
	RemoveJobStatus(ctx context.Context, jobStatusID domain.JobStatusID) error
	RemoveExpiredJobStatus(ctx context.Context) (int, error)
	FindJobStatusByJobName(ctx context.Context, jobName domain.JobName) ([]JobStatus, error)
}

type RepositoryFactory

type RepositoryFactory interface {
	NewJobStatusRepository(ctx context.Context) JobStatusRepository
	NewJobHistoryRepository(ctx context.Context) JobHistoryRepository
}

type Transaction

type Transaction interface {
	Do(ctx context.Context, fn func(rf RepositoryFactory) error) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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