job

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: MPL-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package job package

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CancellationEvent

type CancellationEvent struct {
	Job models.Job
}

CancellationEvent represents a job cancellation event

type CancellationSubscriptionsOptions

type CancellationSubscriptionsOptions struct {
	JobID string
}

CancellationSubscriptionsOptions includes options for setting up a cancellation event subscription

type ClaimJobResponse

type ClaimJobResponse struct {
	JobID string
	Token string
}

ClaimJobResponse is returned when a runner claims a Job

type LogEvent

type LogEvent struct {
	Action string
	JobID  string
	Size   int
}

LogEvent represents a run event

type LogEventSubscriptionOptions

type LogEventSubscriptionOptions struct {
	LastSeenLogSize *int
}

LogEventSubscriptionOptions includes options for setting up a log event subscription

type LogStore

type LogStore interface {
	SaveLogs(ctx context.Context, workspaceID string, runID string, logID string, startOffset int, buffer []byte) error
	GetLogs(ctx context.Context, workspaceID string, runID string, logID string, startOffset int, limit int) ([]byte, error)
}

LogStore interface encapsulates the logic for saving and retrieving logs

func NewLogStore

func NewLogStore(objectStore objectstore.ObjectStore, dbClient *db.Client) LogStore

NewLogStore creates an instance of the LogStore interface

type MockService

type MockService struct {
	mock.Mock
}

MockService is an autogenerated mock type for the Service type

func NewMockService

func NewMockService(t mockConstructorTestingTNewMockService) *MockService

NewMockService creates a new instance of MockService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*MockService) ClaimJob added in v0.8.0

func (_m *MockService) ClaimJob(ctx context.Context, runnerPath string) (*ClaimJobResponse, error)

ClaimJob provides a mock function with given fields: ctx, runnerPath

func (*MockService) GetJob

func (_m *MockService) GetJob(ctx context.Context, jobID string) (*models.Job, error)

GetJob provides a mock function with given fields: ctx, jobID

func (*MockService) GetJobLogDescriptor

func (_m *MockService) GetJobLogDescriptor(ctx context.Context, job *models.Job) (*models.JobLogDescriptor, error)

GetJobLogDescriptor provides a mock function with given fields: ctx, job

func (*MockService) GetJobsByIDs

func (_m *MockService) GetJobsByIDs(ctx context.Context, idList []string) ([]models.Job, error)

GetJobsByIDs provides a mock function with given fields: ctx, idList

func (*MockService) GetLatestJobForRun

func (_m *MockService) GetLatestJobForRun(ctx context.Context, run *models.Run) (*models.Job, error)

GetLatestJobForRun provides a mock function with given fields: ctx, run

func (*MockService) GetLogs

func (_m *MockService) GetLogs(ctx context.Context, jobID string, startOffset int, limit int) ([]byte, error)

GetLogs provides a mock function with given fields: ctx, jobID, startOffset, limit

func (*MockService) SaveLogs

func (_m *MockService) SaveLogs(ctx context.Context, jobID string, startOffset int, buffer []byte) error

SaveLogs provides a mock function with given fields: ctx, jobID, startOffset, buffer

func (*MockService) SubscribeToCancellationEvent

func (_m *MockService) SubscribeToCancellationEvent(ctx context.Context, options *CancellationSubscriptionsOptions) (<-chan *CancellationEvent, error)

SubscribeToCancellationEvent provides a mock function with given fields: ctx, options

func (*MockService) SubscribeToJobLogEvents

func (_m *MockService) SubscribeToJobLogEvents(ctx context.Context, job *models.Job, options *LogEventSubscriptionOptions) (<-chan *LogEvent, error)

SubscribeToJobLogEvents provides a mock function with given fields: ctx, job, options

type Service

type Service interface {
	ClaimJob(ctx context.Context, runnerPath string) (*ClaimJobResponse, error)
	GetJob(ctx context.Context, jobID string) (*models.Job, error)
	GetJobsByIDs(ctx context.Context, idList []string) ([]models.Job, error)
	GetLatestJobForRun(ctx context.Context, run *models.Run) (*models.Job, error)
	SubscribeToCancellationEvent(ctx context.Context, options *CancellationSubscriptionsOptions) (<-chan *CancellationEvent, error)
	SaveLogs(ctx context.Context, jobID string, startOffset int, buffer []byte) error
	GetLogs(ctx context.Context, jobID string, startOffset int, limit int) ([]byte, error)
	GetJobLogDescriptor(ctx context.Context, job *models.Job) (*models.JobLogDescriptor, error)
	SubscribeToJobLogEvents(ctx context.Context, job *models.Job, options *LogEventSubscriptionOptions) (<-chan *LogEvent, error)
}

Service implements all job related functionality

func NewService

func NewService(
	logger logger.Logger,
	dbClient *db.Client,
	idp *auth.IdentityProvider,
	eventManager *events.EventManager,
	runStateManager *state.RunStateManager,
	logStore LogStore,
) Service

NewService creates an instance of Service

Jump to

Keyboard shortcuts

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