job

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package job defines utilities for managing jobs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IAsynchronousJob

type IAsynchronousJob interface {
	resource.IResource
	// GetDone returns whether a job has terminated.
	GetDone() bool
	// GetError returns whether a system error occurred.
	GetError() bool
	// GetFailure returns whether the job has failed.
	GetFailure() bool
	// GetSuccess returns whether the job has been successful.
	GetSuccess() bool
	// GetStatus returns the state the job is in. This is for information only and should not be relied upon as likely to change. Use flags for implementing a state machine.
	GetStatus() string
	// GetQueued returns whether the job is being queued and has not started just yet
	GetQueued() bool
	// HasMessages returns whether the job has messages available.
	HasMessages() bool
	// HasArtefacts returns whether the job has artefacts available.
	HasArtefacts() bool
}

IAsynchronousJob defines a typical asynchronous job.

type IJobManager

type IJobManager interface {
	// HasJobCompleted calls the services to determine whether the job has completed.
	HasJobCompleted(ctx context.Context, job IAsynchronousJob) (completed bool, err error)
	// HasJobStarted calls the services to determine whether the job has started.
	HasJobStarted(ctx context.Context, job IAsynchronousJob) (completed bool, err error)
	// WaitForJobCompletion waits for a job to complete. Similar to WaitForJobCompletionWithTimeout but with a timeout set to 5 minutes.
	WaitForJobCompletion(ctx context.Context, job IAsynchronousJob) (err error)
	// WaitForJobCompletionWithTimeout waits for a job to complete but with timeout protection.
	WaitForJobCompletionWithTimeout(ctx context.Context, job IAsynchronousJob, timeout time.Duration) (err error)
}

IJobManager defines a manager of asynchronous jobs

func NewJobManager

func NewJobManager(logger *messages.MessageLoggerFactory, backOffPeriod time.Duration,
	fetchJobStatusFunc func(ctx context.Context, jobName string) (IAsynchronousJob, *http.Response, error),
	fetchJobFirstMessagePageFunc func(ctx context.Context, jobName string) (pagination.IStaticPageStream, *http.Response, error),
	fetchNextJobMessagesPageFunc func(context.Context, pagination.IStaticPage) (pagination.IStaticPage, error),
	fetchFutureJobMessagesPageFunc func(context.Context, pagination.IStaticPageStream) (pagination.IStaticPageStream, error)) (IJobManager, error)

NewJobManager creates a new job manager.

type Manager

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

func (*Manager) FetchJobMessagesFirstPage added in v1.3.3

func (m *Manager) FetchJobMessagesFirstPage(ctx context.Context, job IAsynchronousJob) (page pagination.IStaticPageStream, err error)

func (*Manager) HasJobCompleted

func (m *Manager) HasJobCompleted(ctx context.Context, job IAsynchronousJob) (completed bool, err error)

func (*Manager) HasJobStarted added in v1.5.2

func (m *Manager) HasJobStarted(ctx context.Context, job IAsynchronousJob) (started bool, err error)

func (*Manager) WaitForJobCompletion

func (m *Manager) WaitForJobCompletion(ctx context.Context, job IAsynchronousJob) error

func (*Manager) WaitForJobCompletionWithTimeout added in v1.7.0

func (m *Manager) WaitForJobCompletionWithTimeout(ctx context.Context, job IAsynchronousJob, timeout time.Duration) (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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