job

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: MPL-2.0 Imports: 21 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 Event added in v0.17.0

type Event struct {
	Job    *models.Job
	Action string
}

Event is a job event

type GetJobsInput added in v0.17.0

type GetJobsInput struct {
	// Sort specifies the field to sort on and direction
	Sort *db.JobSortableField
	// PaginationOptions supports cursor based pagination
	PaginationOptions *pagination.Options
	// Status is the job status to filter on
	Status *models.JobStatus
	// Type is the job type to filter on
	Type *models.JobType
	// WorkspaceID is the workspace ID to filter on
	WorkspaceID *string
	// RunnerID filters the jobs by the specified runner ID
	RunnerID *string
}

GetJobsInput includes options for getting jobs

type LogEvent

type LogEvent struct {
	Action string
	JobID  string
	Size   int
}

LogEvent represents a run event

type LogStreamEventSubscriptionOptions added in v0.17.0

type LogStreamEventSubscriptionOptions struct {
	LastSeenLogSize *int
	JobID           string
}

LogStreamEventSubscriptionOptions includes options for setting up a log event subscription

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) GetJobs added in v0.17.0

func (_m *MockService) GetJobs(ctx context.Context, input *GetJobsInput) (*db.JobsResult, error)

GetJobs provides a mock function with given fields: ctx, input

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) GetLogStreamsByJobIDs added in v0.17.0

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

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

func (*MockService) ReadLogs added in v0.17.0

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

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

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) SubscribeToJobs added in v0.17.0

func (_m *MockService) SubscribeToJobs(ctx context.Context, options *SubscribeToJobsInput) (<-chan *Event, error)

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

func (*MockService) SubscribeToLogStreamEvents added in v0.17.0

func (_m *MockService) SubscribeToLogStreamEvents(ctx context.Context, options *LogStreamEventSubscriptionOptions) (<-chan *logstream.LogEvent, error)

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

func (*MockService) WriteLogs added in v0.17.0

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

WriteLogs provides a mock function with given fields: ctx, jobID, startOffset, logs

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)
	GetJobs(ctx context.Context, input *GetJobsInput) (*db.JobsResult, error)
	GetLatestJobForRun(ctx context.Context, run *models.Run) (*models.Job, error)
	SubscribeToCancellationEvent(ctx context.Context, options *CancellationSubscriptionsOptions) (<-chan *CancellationEvent, error)
	WriteLogs(ctx context.Context, jobID string, startOffset int, logs []byte) (int, error)
	ReadLogs(ctx context.Context, jobID string, startOffset int, limit int) ([]byte, error)
	SubscribeToLogStreamEvents(ctx context.Context, options *LogStreamEventSubscriptionOptions) (<-chan *logstream.LogEvent, error)
	GetLogStreamsByJobIDs(ctx context.Context, idList []string) ([]models.LogStream, error)
	SubscribeToJobs(ctx context.Context, options *SubscribeToJobsInput) (<-chan *Event, error)
}

Service implements all job related functionality

func NewService

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

NewService creates an instance of Service

type SubscribeToJobsInput added in v0.17.0

type SubscribeToJobsInput struct {
	WorkspaceID *string
	RunnerID    *string
}

SubscribeToJobsInput is the input for subscribing to jobs

Jump to

Keyboard shortcuts

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