service

package
v0.0.0-...-5b7b456 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IService

type IService interface {
	Init() error
	Stop() error
	Finalize() error
	GetJobsCount() uint
	GetJobsUUIDs() job.JobUUIDList
	LoadJobs() error
	GetJob(job.JobUUID) (*job.Job, error)
	GetAllJobs() ([]*job.Job, error)
	CreateJob(payload []byte) (*job.Job, error)
	PullJobs(*RequestPullJobs) (*ResponsePullJobs, error)
	StartJob(job.JobUUID, *RequestPullJobs) error
	CloneJob(job.JobUUID) (*job.Job, error)
	CancelJob(job.JobUUID) error
	SetJobAsSuccessful(job.JobUUID) error
	FailJob(job.JobUUID) error
	DeleteJob(job.JobUUID) error
	DeleteAllJobs() error
	GenerateNewJobUuid() (job.JobUUID, error)
	GetLockedResources() (job.LockedResources, error)
	UnlockAllResources() error
	ChangeVisibilityTimeoutJob(job.JobUUID, uint) error
	Healthcheck() bool
	ComputeMetrics() error
	TryEnqueuePendingJobs()
	Watchdog()
	GetServiceEventChan() chan ServiceEvent
	GetLogger() *zap.Logger
}

type RequestPullJobs

type RequestPullJobs struct {
	JobUUID           *job.JobUUID // if nil pull any job, else pull the specific job
	Topic             string       // topic to pull the job from (if empty pull from any topic)
	NumJobs           uint         // number of jobs to pull (if 0 pull only one job)
	VisibilityTimeout uint         // parameter to hide the job for a specific duration
	WaitTimeSeconds   uint         // parameter enables long-poll (if 0 return immediately if no job available)
}

type ResponsePullJobs

type ResponsePullJobs struct {
	Jobs []*job.Job `json:"jobs"`
}

type Service

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

func CreateAndInitService

func CreateAndInitService(conf *config.Config) (*Service, error)

func NewService

func NewService(logger *zap.Logger, conf *config.Config) (*Service, error)

func (*Service) CancelJob

func (svc *Service) CancelJob(jobUUID job.JobUUID) error

func (*Service) ChangeVisibilityTimeoutJob

func (svc *Service) ChangeVisibilityTimeoutJob(jobUUID job.JobUUID, visibilityTimeout uint) error

func (*Service) CheckJobsRetention

func (svc *Service) CheckJobsRetention() error

func (*Service) CloneJob

func (svc *Service) CloneJob(jobUUID job.JobUUID) (*job.Job, error)

func (*Service) ComputeLockedResources

func (svc *Service) ComputeLockedResources(jobs job.JobMap) job.LockedResources

func (*Service) ComputeMetrics

func (svc *Service) ComputeMetrics() error

func (*Service) CreateJob

func (svc *Service) CreateJob(payload []byte) (*job.Job, error)

func (*Service) DeleteAllJobs

func (svc *Service) DeleteAllJobs() error

func (*Service) DeleteJob

func (svc *Service) DeleteJob(jobUUID job.JobUUID) error

func (*Service) EnqueueJob

func (svc *Service) EnqueueJob(j *job.Job) error

func (*Service) FailJob

func (svc *Service) FailJob(jobUUID job.JobUUID) error

func (*Service) Finalize

func (svc *Service) Finalize() error

func (*Service) FinalizeJobCreation

func (svc *Service) FinalizeJobCreation(j *job.Job) (*job.Job, error)

func (*Service) FindBestJobCandidates

func (svc *Service) FindBestJobCandidates(req *RequestPullJobs) ([]*job.Job, error)

func (*Service) GenerateNewJobUuid

func (svc *Service) GenerateNewJobUuid() (job.JobUUID, error)

func (*Service) GetAllJobs

func (svc *Service) GetAllJobs() ([]*job.Job, error)

func (*Service) GetJob

func (svc *Service) GetJob(uuid job.JobUUID) (*job.Job, error)

func (*Service) GetJobsCount

func (svc *Service) GetJobsCount() uint

func (*Service) GetJobsUUIDs

func (svc *Service) GetJobsUUIDs() job.JobUUIDList

func (*Service) GetLockedResources

func (svc *Service) GetLockedResources() (job.LockedResources, error)

func (*Service) GetLogger

func (svc *Service) GetLogger() *zap.Logger

func (*Service) GetServiceEventChan

func (svc *Service) GetServiceEventChan() chan ServiceEvent

func (*Service) Healthcheck

func (svc *Service) Healthcheck() bool

func (*Service) Init

func (svc *Service) Init() error

func (*Service) LoadJobs

func (svc *Service) LoadJobs() error

func (*Service) PullJobs

func (svc *Service) PullJobs(req *RequestPullJobs) (*ResponsePullJobs, error)

func (*Service) PullSpecificJob

func (svc *Service) PullSpecificJob(req *RequestPullJobs) (*ResponsePullJobs, error)

func (*Service) Run

func (svc *Service) Run() error

func (*Service) SetJobAsSuccessful

func (svc *Service) SetJobAsSuccessful(jobUUID job.JobUUID) error

func (*Service) StartJob

func (svc *Service) StartJob(jobUUID job.JobUUID, req *RequestPullJobs) error

func (*Service) Stop

func (svc *Service) Stop() error

func (*Service) TryEnqueuePendingJobs

func (svc *Service) TryEnqueuePendingJobs()

func (*Service) UnlockAllResources

func (svc *Service) UnlockAllResources() error

func (*Service) UnlockJobResources

func (svc *Service) UnlockJobResources(j *job.Job) error

func (*Service) Watchdog

func (svc *Service) Watchdog()

type ServiceEvent

type ServiceEvent struct {
	Type    ServiceEventType
	Metrics ServiceMetrics
	JobUUID job.JobUUID
}

type ServiceEventType

type ServiceEventType int

ServiceEventType is a int type that represents the type of event that can be sent by the service

const (
	// ServiceEventJobCreated is an event that is sent when a job is created
	ServiceEventJobCreated ServiceEventType = iota
	// ServiceEventJobEnqueued is an event that is sent when a job is enqueued
	ServiceEventJobEnqueued
	// ServiceEventJobStarted is an event that is sent when a job is started
	ServiceEventJobStarted
	// ServiceEventJobSucceeded is an event that is sent when a job is succeeded
	ServiceEventJobSucceeded
	// ServiceEventJobCanceled is an event that is sent when a job is canceled
	ServiceEventJobCanceled
	// ServiceEventJobDeleted is an event that is sent when a job is deleted
	ServiceEventJobDeleted
	// ServiceEventJobTimeout is an event that is sent when a job is timeout
	ServiceEventJobTimeout
	// ServiceEventJobDeletedAll is an event that is sent when all jobs are deleted
	ServiceEventJobDeletedAll
	// ServiceEventJobUnlockedAllResources is an event that is sent when all resources are unlocked
	ServiceEventJobUnlockedAllResources
	// ServiceEventJobHealthcheck is an event that is sent when the healthcheck is called
	ServiceEventJobHealthcheck
	// ServiceEventJobMetrics is an event that is sent when the metrics are computed
	ServiceEventJobMetrics
	// ServiceEventJobWatchdog is an event that is sent when the watchdog is called
	ServiceEventJobWatchdog
	// ServiceEventShutdown is an event that is sent when the service is shutdown
	ServiceEventShutdown
)

type ServiceMetrics

type ServiceMetrics struct {
	ResourcesLockedCount uint // number of current locked resources
	JobsCount            uint // number of current existing jobs
	JobsCounterCreated   uint // counter of total created jobs
	JobsCounterPending   uint // counter of total pending jobs
	JobsCounterQueued    uint // counter of total queued jobs
	JobsCounterRunning   uint // counter of total running jobs
	JobsCounterSucceeded uint // counter of total succeeded jobs
	JobsCounterFailed    uint // counter of total failed jobs
	JobsCounterTimeout   uint // counter of total timeout jobs
	JobsCounterDeleted   uint // counter of total deleted jobs
	JobsCounterCanceled  uint // counter of total canceled jobs
	JobsCounterFaillure  uint // counter of total faillure jobs (this is not related to the status of the job)
}

Jump to

Keyboard shortcuts

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