job

package module
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 15 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

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, jobTimeout time.Duration) (err error)
	// GetMessagePaginator returns a paginator over job messages. The timeout corresponds to the time given to obtain the paginator
	GetMessagePaginator(ctx context.Context, logger logs.Loggers, job IAsynchronousJob, setupTimeout time.Duration) (pagination.IStreamPaginatorAndPageFetcher, error)
	// LogJobMessagesUntilNow logs all the job messages until now unless the loggingTimeout is reached beforehand. This is doing the same as WaitForJobCompletionWithTimeout apart from waiting for job completion.
	LogJobMessagesUntilNow(ctx context.Context, job IAsynchronousJob, loggingTimeout 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

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

func (*Manager) GetMessagePaginator

func (m *Manager) GetMessagePaginator(ctx context.Context, logger logs.Loggers, job IAsynchronousJob, timeout time.Duration) (messagePaginator pagination.IStreamPaginatorAndPageFetcher, err error)

func (*Manager) HasJobCompleted

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

func (*Manager) HasJobStarted

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

func (*Manager) LogJobMessagesUntilNow

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

func (*Manager) WaitForJobCompletion

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

func (*Manager) WaitForJobCompletionWithTimeout

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

Directories

Path Synopsis
jobtest module

Jump to

Keyboard shortcuts

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