job

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2023 License: Apache-2.0 Imports: 13 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
}

IAsynchronousJob defines a typical asynchronous job.

func NewMockFailedAsynchronousJob

func NewMockFailedAsynchronousJob() (IAsynchronousJob, error)

func NewMockSuccessfulAsynchronousJob

func NewMockSuccessfulAsynchronousJob() (IAsynchronousJob, error)

func NewMockUndoneAsynchronousJob

func NewMockUndoneAsynchronousJob() (IAsynchronousJob, error)

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)

	// WaitForJobCompletion waits for a job to complete.
	WaitForJobCompletion(ctx context.Context, job IAsynchronousJob) (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) WaitForJobCompletion

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

type MockAsynchronousJob

type MockAsynchronousJob struct {
	resource.IResource
	// contains filtered or unexported fields
}

func (*MockAsynchronousJob) FetchType

func (m *MockAsynchronousJob) FetchType() string

func (*MockAsynchronousJob) GetDone

func (m *MockAsynchronousJob) GetDone() bool

func (*MockAsynchronousJob) GetError

func (m *MockAsynchronousJob) GetError() bool

func (*MockAsynchronousJob) GetFailure

func (m *MockAsynchronousJob) GetFailure() bool

func (*MockAsynchronousJob) GetStatus

func (m *MockAsynchronousJob) GetStatus() string

func (*MockAsynchronousJob) GetSuccess

func (m *MockAsynchronousJob) GetSuccess() bool

Jump to

Keyboard shortcuts

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