persistence

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterStorage

func RegisterStorage(name string, storage Storage)

RegisterStorage registers a new storage.

func Storages

func Storages() []string

Storages returns a list containing the names of all supported storages.

Types

type FetchParams

type FetchParams struct {
	// History, when set to true, includes the transition history of the job in the fetched data.
	History bool
}

FetchParams control the level of detail returned by fetch operations. By default, all boolean parameters are false in Go. If you add a new parameter, ensure that `false` represents the sensible default value.

type FilterParams

type FilterParams struct {
	// ClientID allows filtering jobs that belong to a specific client.
	// Only jobs with a matching client ID will be returned.
	ClientID *string
	// Group allows filtering jobs that belong to one of the specified groups.
	// The filter is an OR filter, meaning jobs that belong to any of the provided groups will be returned.
	Group []string
	// State allows filtering jobs based on their current state value.
	// Only jobs with a matching state will be returned.
	State *string
	// Workflow allows filtering jobs that are created from a specific workflow.
	// Only jobs with a matching workflow name will be returned.
	Workflow *string
	// Tags allows filtering jobs that contain one or more of the specified tags.
	// The filter is an OR filter, meaning jobs that contain any of the provided tags will be returned.
	Tags []string
}

FilterParams define criteria for filtering jobs. Each field represents a different filter that can be applied. A job entity has to match all criteria in order to be returned.

type JobUpdate

type JobUpdate struct {
	// Status is the new job status. If provided, it replaces the existing status of the job.
	Status *model.JobStatus
	// Definition is the new job definition. If provided, it replaces the existing job definition.
	Definition *map[string]any
	// AddTags is a list of tags to be added to the job. If provided, these tags will be added to the existing tags.
	AddTags *[]string
	// DelTags is a list of tags to be removed from the job. If provided, these tags will be
	// removed from the job's existing tags. If a tag specified here does not exist in the
	// job's tags, it will be ignored.
	DelTags *[]string
}

JobUpdate encapsulates the properties of a job that can be updated. If a property is nil, its corresponding value in the job will not be changed.

type MockStorage added in v0.2.0

type MockStorage struct {
	mock.Mock
}

MockStorage is an autogenerated mock type for the Storage type

func NewMockStorage added in v0.2.0

func NewMockStorage(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockStorage

NewMockStorage creates a new instance of MockStorage. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockStorage) CheckHealth added in v0.2.0

func (_m *MockStorage) CheckHealth(ctx context.Context) error

CheckHealth provides a mock function with given fields: ctx

func (*MockStorage) CreateJob added in v0.2.0

func (_m *MockStorage) CreateJob(ctx context.Context, job *model.Job) (*model.Job, error)

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

func (*MockStorage) CreateWorkflow added in v0.2.0

func (_m *MockStorage) CreateWorkflow(ctx context.Context, workflow *model.Workflow) (*model.Workflow, error)

CreateWorkflow provides a mock function with given fields: ctx, workflow

func (*MockStorage) DeleteJob added in v0.2.0

func (_m *MockStorage) DeleteJob(ctx context.Context, jobID string) error

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

func (*MockStorage) DeleteWorkflow added in v0.2.0

func (_m *MockStorage) DeleteWorkflow(ctx context.Context, name string) error

DeleteWorkflow provides a mock function with given fields: ctx, name

func (*MockStorage) EXPECT added in v0.2.0

func (_m *MockStorage) EXPECT() *MockStorage_Expecter

func (*MockStorage) GetJob added in v0.2.0

func (_m *MockStorage) GetJob(ctx context.Context, jobID string, fetchParams FetchParams) (*model.Job, error)

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

func (*MockStorage) GetWorkflow added in v0.2.0

func (_m *MockStorage) GetWorkflow(ctx context.Context, name string) (*model.Workflow, error)

GetWorkflow provides a mock function with given fields: ctx, name

func (*MockStorage) Initialize added in v0.2.0

func (_m *MockStorage) Initialize(ctx context.Context, options string) error

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

func (*MockStorage) QueryJobs added in v0.2.0

func (_m *MockStorage) QueryJobs(ctx context.Context, filterParams FilterParams, sortParams SortParams, paginationParams PaginationParams) (*model.PaginatedJobList, error)

QueryJobs provides a mock function with given fields: ctx, filterParams, sortParams, paginationParams

func (*MockStorage) QueryWorkflows added in v0.2.0

func (_m *MockStorage) QueryWorkflows(ctx context.Context, paginationParams PaginationParams) (*model.PaginatedWorkflowList, error)

QueryWorkflows provides a mock function with given fields: ctx, paginationParams

func (*MockStorage) Shutdown added in v0.2.0

func (_m *MockStorage) Shutdown()

Shutdown provides a mock function with given fields:

func (*MockStorage) UpdateJob added in v0.2.0

func (_m *MockStorage) UpdateJob(ctx context.Context, job *model.Job, request JobUpdate) (*model.Job, error)

UpdateJob provides a mock function with given fields: ctx, job, request

type MockStorage_CheckHealth_Call added in v0.2.0

type MockStorage_CheckHealth_Call struct {
	*mock.Call
}

MockStorage_CheckHealth_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CheckHealth'

func (*MockStorage_CheckHealth_Call) Return added in v0.2.0

func (*MockStorage_CheckHealth_Call) Run added in v0.2.0

func (*MockStorage_CheckHealth_Call) RunAndReturn added in v0.2.0

type MockStorage_CreateJob_Call added in v0.2.0

type MockStorage_CreateJob_Call struct {
	*mock.Call
}

MockStorage_CreateJob_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateJob'

func (*MockStorage_CreateJob_Call) Return added in v0.2.0

func (*MockStorage_CreateJob_Call) Run added in v0.2.0

func (*MockStorage_CreateJob_Call) RunAndReturn added in v0.2.0

type MockStorage_CreateWorkflow_Call added in v0.2.0

type MockStorage_CreateWorkflow_Call struct {
	*mock.Call
}

MockStorage_CreateWorkflow_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateWorkflow'

func (*MockStorage_CreateWorkflow_Call) Return added in v0.2.0

func (*MockStorage_CreateWorkflow_Call) Run added in v0.2.0

func (*MockStorage_CreateWorkflow_Call) RunAndReturn added in v0.2.0

type MockStorage_DeleteJob_Call added in v0.2.0

type MockStorage_DeleteJob_Call struct {
	*mock.Call
}

MockStorage_DeleteJob_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteJob'

func (*MockStorage_DeleteJob_Call) Return added in v0.2.0

func (*MockStorage_DeleteJob_Call) Run added in v0.2.0

func (*MockStorage_DeleteJob_Call) RunAndReturn added in v0.2.0

type MockStorage_DeleteWorkflow_Call added in v0.2.0

type MockStorage_DeleteWorkflow_Call struct {
	*mock.Call
}

MockStorage_DeleteWorkflow_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteWorkflow'

func (*MockStorage_DeleteWorkflow_Call) Return added in v0.2.0

func (*MockStorage_DeleteWorkflow_Call) Run added in v0.2.0

func (*MockStorage_DeleteWorkflow_Call) RunAndReturn added in v0.2.0

type MockStorage_Expecter added in v0.2.0

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

func (*MockStorage_Expecter) CheckHealth added in v0.2.0

func (_e *MockStorage_Expecter) CheckHealth(ctx interface{}) *MockStorage_CheckHealth_Call

CheckHealth is a helper method to define mock.On call

  • ctx context.Context

func (*MockStorage_Expecter) CreateJob added in v0.2.0

func (_e *MockStorage_Expecter) CreateJob(ctx interface{}, job interface{}) *MockStorage_CreateJob_Call

CreateJob is a helper method to define mock.On call

  • ctx context.Context
  • job *model.Job

func (*MockStorage_Expecter) CreateWorkflow added in v0.2.0

func (_e *MockStorage_Expecter) CreateWorkflow(ctx interface{}, workflow interface{}) *MockStorage_CreateWorkflow_Call

CreateWorkflow is a helper method to define mock.On call

  • ctx context.Context
  • workflow *model.Workflow

func (*MockStorage_Expecter) DeleteJob added in v0.2.0

func (_e *MockStorage_Expecter) DeleteJob(ctx interface{}, jobID interface{}) *MockStorage_DeleteJob_Call

DeleteJob is a helper method to define mock.On call

  • ctx context.Context
  • jobID string

func (*MockStorage_Expecter) DeleteWorkflow added in v0.2.0

func (_e *MockStorage_Expecter) DeleteWorkflow(ctx interface{}, name interface{}) *MockStorage_DeleteWorkflow_Call

DeleteWorkflow is a helper method to define mock.On call

  • ctx context.Context
  • name string

func (*MockStorage_Expecter) GetJob added in v0.2.0

func (_e *MockStorage_Expecter) GetJob(ctx interface{}, jobID interface{}, fetchParams interface{}) *MockStorage_GetJob_Call

GetJob is a helper method to define mock.On call

  • ctx context.Context
  • jobID string
  • fetchParams FetchParams

func (*MockStorage_Expecter) GetWorkflow added in v0.2.0

func (_e *MockStorage_Expecter) GetWorkflow(ctx interface{}, name interface{}) *MockStorage_GetWorkflow_Call

GetWorkflow is a helper method to define mock.On call

  • ctx context.Context
  • name string

func (*MockStorage_Expecter) Initialize added in v0.2.0

func (_e *MockStorage_Expecter) Initialize(ctx interface{}, options interface{}) *MockStorage_Initialize_Call

Initialize is a helper method to define mock.On call

  • ctx context.Context
  • options string

func (*MockStorage_Expecter) QueryJobs added in v0.2.0

func (_e *MockStorage_Expecter) QueryJobs(ctx interface{}, filterParams interface{}, sortParams interface{}, paginationParams interface{}) *MockStorage_QueryJobs_Call

QueryJobs is a helper method to define mock.On call

  • ctx context.Context
  • filterParams FilterParams
  • sortParams SortParams
  • paginationParams PaginationParams

func (*MockStorage_Expecter) QueryWorkflows added in v0.2.0

func (_e *MockStorage_Expecter) QueryWorkflows(ctx interface{}, paginationParams interface{}) *MockStorage_QueryWorkflows_Call

QueryWorkflows is a helper method to define mock.On call

  • ctx context.Context
  • paginationParams PaginationParams

func (*MockStorage_Expecter) Shutdown added in v0.2.0

Shutdown is a helper method to define mock.On call

func (*MockStorage_Expecter) UpdateJob added in v0.2.0

func (_e *MockStorage_Expecter) UpdateJob(ctx interface{}, job interface{}, request interface{}) *MockStorage_UpdateJob_Call

UpdateJob is a helper method to define mock.On call

  • ctx context.Context
  • job *model.Job
  • request JobUpdate

type MockStorage_GetJob_Call added in v0.2.0

type MockStorage_GetJob_Call struct {
	*mock.Call
}

MockStorage_GetJob_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetJob'

func (*MockStorage_GetJob_Call) Return added in v0.2.0

func (*MockStorage_GetJob_Call) Run added in v0.2.0

func (_c *MockStorage_GetJob_Call) Run(run func(ctx context.Context, jobID string, fetchParams FetchParams)) *MockStorage_GetJob_Call

func (*MockStorage_GetJob_Call) RunAndReturn added in v0.2.0

type MockStorage_GetWorkflow_Call added in v0.2.0

type MockStorage_GetWorkflow_Call struct {
	*mock.Call
}

MockStorage_GetWorkflow_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWorkflow'

func (*MockStorage_GetWorkflow_Call) Return added in v0.2.0

func (*MockStorage_GetWorkflow_Call) Run added in v0.2.0

func (*MockStorage_GetWorkflow_Call) RunAndReturn added in v0.2.0

type MockStorage_Initialize_Call added in v0.2.0

type MockStorage_Initialize_Call struct {
	*mock.Call
}

MockStorage_Initialize_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Initialize'

func (*MockStorage_Initialize_Call) Return added in v0.2.0

func (*MockStorage_Initialize_Call) Run added in v0.2.0

func (*MockStorage_Initialize_Call) RunAndReturn added in v0.2.0

type MockStorage_QueryJobs_Call added in v0.2.0

type MockStorage_QueryJobs_Call struct {
	*mock.Call
}

MockStorage_QueryJobs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'QueryJobs'

func (*MockStorage_QueryJobs_Call) Return added in v0.2.0

func (*MockStorage_QueryJobs_Call) Run added in v0.2.0

func (_c *MockStorage_QueryJobs_Call) Run(run func(ctx context.Context, filterParams FilterParams, sortParams SortParams, paginationParams PaginationParams)) *MockStorage_QueryJobs_Call

func (*MockStorage_QueryJobs_Call) RunAndReturn added in v0.2.0

type MockStorage_QueryWorkflows_Call added in v0.2.0

type MockStorage_QueryWorkflows_Call struct {
	*mock.Call
}

MockStorage_QueryWorkflows_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'QueryWorkflows'

func (*MockStorage_QueryWorkflows_Call) Return added in v0.2.0

func (*MockStorage_QueryWorkflows_Call) Run added in v0.2.0

func (*MockStorage_QueryWorkflows_Call) RunAndReturn added in v0.2.0

type MockStorage_Shutdown_Call added in v0.2.0

type MockStorage_Shutdown_Call struct {
	*mock.Call
}

MockStorage_Shutdown_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Shutdown'

func (*MockStorage_Shutdown_Call) Return added in v0.2.0

func (*MockStorage_Shutdown_Call) Run added in v0.2.0

func (*MockStorage_Shutdown_Call) RunAndReturn added in v0.2.0

func (_c *MockStorage_Shutdown_Call) RunAndReturn(run func()) *MockStorage_Shutdown_Call

type MockStorage_UpdateJob_Call added in v0.2.0

type MockStorage_UpdateJob_Call struct {
	*mock.Call
}

MockStorage_UpdateJob_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateJob'

func (*MockStorage_UpdateJob_Call) Return added in v0.2.0

func (*MockStorage_UpdateJob_Call) Run added in v0.2.0

func (*MockStorage_UpdateJob_Call) RunAndReturn added in v0.2.0

type PaginationParams

type PaginationParams struct {
	// Offset is the number of items to skip before starting to collect results.
	Offset int64
	// Limit is the maximum number of items to return in the response.
	Limit int32
}

PaginationParams controls the pagination of response lists. It allows the client to specify a subset of results to return, which can be useful for large data sets.

type SortParams

type SortParams struct {
	// Desc, when set to true, sorts the jobs in descending order based on their creation time.
	// When set to false, the jobs are sorted in ascending order.
	Desc bool
}

SortParams specify the order of the returned jobs.

type Storage

type Storage interface {
	// Initialize sets up the storage using the provided options string.
	Initialize(ctx context.Context, options string) error

	// Shutdown gracefully closes the storage connection.
	Shutdown()

	// CheckHealth examines the status of the storage, returning an error if the storage is not available.
	CheckHealth(ctx context.Context) error

	// CreateJob adds a new job to the storage.
	CreateJob(ctx context.Context, job *model.Job) (*model.Job, error)

	// GetJob retrieves an existing job identified by jobID from the storage.
	// If an issue occurs during the fetch operation, the method returns an error.
	GetJob(ctx context.Context, jobID string, fetchParams FetchParams) (*model.Job, error)

	// UpdateJob modifies an existing job in the storage based on the provided JobUpdate request.
	UpdateJob(ctx context.Context, job *model.Job, request JobUpdate) (*model.Job, error)

	// DeleteJob removes an existing job identified by jobID from the storage.
	DeleteJob(ctx context.Context, jobID string) error

	// QueryJobs retrieves jobs that satisfy the filterParams, sortParams, and paginationParams.
	QueryJobs(ctx context.Context, filterParams FilterParams, sortParams SortParams, paginationParams PaginationParams) (*model.PaginatedJobList, error)

	// CreateWorkflow adds a new workflow to the storage.
	CreateWorkflow(ctx context.Context, workflow *model.Workflow) (*model.Workflow, error)

	// GetWorkflow retrieves an existing workflow identified by name from the storage.
	// If an issue occurs during the fetch operation, the method returns an error.
	GetWorkflow(ctx context.Context, name string) (*model.Workflow, error)

	// DeleteWorkflow removes an existing workflow identified by name from the storage.
	DeleteWorkflow(ctx context.Context, name string) error

	// QueryWorkflows retrieves all workflows from the storage respecting the paginationParams.
	QueryWorkflows(ctx context.Context, paginationParams PaginationParams) (*model.PaginatedWorkflowList, error)
}

Storage represents an interface for a persistence layer (such as PostgreSQL, SQLite). It provides methods for managing jobs and workflows in the storage.

func GetStorage

func GetStorage(name string) Storage

GetStorage returns the storage with the given name.

Jump to

Keyboard shortcuts

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