workflows

package
v0.0.0-...-a87bc67 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCurrentCluster

func GetCurrentCluster(ctx context.Context) (string, error)

func NewJobClient

func NewJobClient(options ...ClientOption) workflowsv1connect.JobServiceClient

func NewTaskClient

func NewTaskClient(options ...ClientOption) workflowsv1connect.TaskServiceClient

func SubmitSubtasks

func SubmitSubtasks(ctx context.Context, tasks ...Task) error

func ValidateIdentifier

func ValidateIdentifier(identifier TaskIdentifier) error

ValidateIdentifier performs client-side validation on a task identifier.

func WithTaskSpan

func WithTaskSpan(ctx context.Context, name string, f func(ctx context.Context) error) error

func WithTaskSpanResult

func WithTaskSpanResult[Result any](ctx context.Context, name string, f func(ctx context.Context) (Result, error)) (Result, error)

Types

type ClientOption

type ClientOption func(*clientConfig)

ClientOption is an interface for configuring a client. Using such options helpers is a quite common pattern in Go, as it allows for optional parameters in constructors. This concrete implementation here is inspired by how libraries such as axiom-go and connect do their configuration.

func WithAPIKey

func WithAPIKey(apiKey string) ClientOption

func WithConnectClientOptions

func WithConnectClientOptions(options ...connect.ClientOption) ClientOption

func WithHTTPClient

func WithHTTPClient(httpClient connect.HTTPClient) ClientOption

func WithURL

func WithURL(url string) ClientOption

type ContextKeyTaskExecutionType

type ContextKeyTaskExecutionType string
const ContextKeyTaskExecution ContextKeyTaskExecutionType = "x-tilebox-task-execution-object"

type ExecutableTask

type ExecutableTask interface {
	Execute(ctx context.Context) error
}

ExecutableTask is the interface for a task that can be executed, and therefore be registered with a task runner.

type ExplicitlyIdentifiableTask

type ExplicitlyIdentifiableTask interface {
	Identifier() TaskIdentifier
}

ExplicitlyIdentifiableTask is the interface for a task that provides a user-defined task identifier. The identifier is used to uniquely identify the task and specify its version. If a task is not an ExplicitlyIdentifiableTask, the task runner will generate an identifier for it using reflection.

type JobService

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

func NewJobService

func NewJobService(client workflowsv1connect.JobServiceClient, options ...JobServiceOption) *JobService

func (*JobService) Submit

func (js *JobService) Submit(ctx context.Context, jobName, clusterSlug string, maxRetries int, tasks ...Task) (*workflowsv1.Job, error)

type JobServiceOption

type JobServiceOption func(*jobServiceConfig)

func WithJobServiceTracerName

func WithJobServiceTracerName(tracerName string) JobServiceOption

func WithJobServiceTracerProvider

func WithJobServiceTracerProvider(tracerProvider trace.TracerProvider) JobServiceOption

type RecurrentTaskService

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

func (*RecurrentTaskService) CreateStorageLocation

func (rs *RecurrentTaskService) CreateStorageLocation(ctx context.Context, location string, storageType workflowsv1.StorageType) (*workflowsv1.StorageLocation, error)

func (*RecurrentTaskService) DeleteStorageLocation

func (rs *RecurrentTaskService) DeleteStorageLocation(ctx context.Context, storageLocationID *workflowsv1.UUID) error

func (*RecurrentTaskService) GetStorageLocation

func (rs *RecurrentTaskService) GetStorageLocation(ctx context.Context, storageLocationID *workflowsv1.UUID) (*workflowsv1.StorageLocation, error)

func (*RecurrentTaskService) ListStorageLocations

func (rs *RecurrentTaskService) ListStorageLocations(ctx context.Context) ([]*workflowsv1.StorageLocation, error)

type Task

type Task interface {
}

Task is the interface for a task that can be submitted to the workflow service. It doesn't need to be identifiable or executable, but it can be both.

type TaskIdentifier

type TaskIdentifier interface {
	Name() string
	Version() string
	Display() string
}

func NewTaskIdentifier

func NewTaskIdentifier(name, version string) TaskIdentifier

type TaskRunner

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

func NewTaskRunner

func NewTaskRunner(client workflowsv1connect.TaskServiceClient, options ...TaskRunnerOption) (*TaskRunner, error)

func (*TaskRunner) GetRegisteredTask

func (t *TaskRunner) GetRegisteredTask(identifier TaskIdentifier) (ExecutableTask, bool)

func (*TaskRunner) RegisterTask

func (t *TaskRunner) RegisterTask(task ExecutableTask) error

func (*TaskRunner) RegisterTasks

func (t *TaskRunner) RegisterTasks(tasks ...ExecutableTask) error

func (*TaskRunner) Run

func (t *TaskRunner) Run(ctx context.Context)

Run runs the task runner forever, looking for new tasks to run and polling for new tasks when idle.

type TaskRunnerOption

type TaskRunnerOption func(*taskRunnerConfig)

func WithCluster

func WithCluster(clusterSlug string) TaskRunnerOption

func WithLogExecutionTimes

func WithLogExecutionTimes(logExecutionTimes bool) TaskRunnerOption

func WithRunnerLogger

func WithRunnerLogger(logger *slog.Logger) TaskRunnerOption

func WithRunnerTracerName

func WithRunnerTracerName(tracerName string) TaskRunnerOption

func WithRunnerTracerProvider

func WithRunnerTracerProvider(tracerProvider trace.TracerProvider) TaskRunnerOption

Jump to

Keyboard shortcuts

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