abstractions

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type QueryFilter added in v0.2.0

type QueryFilter struct {
	Limit  int
	Offset int
	Params map[string]any
	// Make tenant explicit because it is not a user parameter
	Tenant api.Tenant
}

func (*QueryFilter) ExtractQueryParams added in v0.2.0

func (filter *QueryFilter) ExtractQueryParams() *QueryFilter

Returns the limit, offset, and filtered params

func (*QueryFilter) String added in v0.2.0

func (filter *QueryFilter) String() string

type QueryResults

type QueryResults[T any] struct {
	Items      []T
	TotalCount int
	Errors     []string
}

type Runtime

type Runtime interface {
	WithLogger(logger *slog.Logger) Runtime
	WithContext(ctx context.Context) Runtime
	Name() string
	RunEvaluationJob(evaluation *api.EvaluationJobResource, storage Storage) error
	DeleteEvaluationJobResources(evaluation *api.EvaluationJobResource) error
}

type ServiceError

type ServiceError interface {
	Error() string                      // This allows this to be used with the error interface
	MessageCode() *messages.MessageCode // The message code to return to the caller
	MessageParams() []any               // The parameters to the message code
	ShouldRollback() bool               // Whether the transaction should be rolled back due to this error
}

ServiceError is an interface that represents an error in the service. It is used to return errors from the service to the caller. Error() can be used to log the error in the service, MessageCode() and MessageParams() can be used to return the error to the caller. The generation of the error message for the caller is done in the top level of the service where i18n can be implemented if required.

type Storage

type Storage interface {
	WithLogger(logger *slog.Logger) Storage
	WithContext(ctx context.Context) Storage
	WithTenant(tenant api.Tenant) Storage
	WithOwner(owner api.User) Storage

	Ping(timeout time.Duration) error

	// Evaluation job operations
	CreateEvaluationJob(evaluation *api.EvaluationJobResource) error
	GetEvaluationJob(id string) (*api.EvaluationJobResource, error)
	GetEvaluationJobs(filter *QueryFilter) (*QueryResults[api.EvaluationJobResource], error)
	DeleteEvaluationJob(id string) error
	UpdateEvaluationJob(id string, runStatus *api.StatusEvent, benchmarks []api.BenchmarkConfig) error
	// UpdateEvaluationJobStatus is used to update the status of an evaluation job and is internal - do we need it here?
	UpdateEvaluationJobStatus(id string, state api.OverallState, message *api.MessageInfo) error

	// Collection operations
	CreateCollection(collection *api.CollectionResource) error
	GetCollection(id string) (*api.CollectionResource, error)
	GetCollections(filter *QueryFilter) (*QueryResults[api.CollectionResource], error)
	UpdateCollection(id string, collection *api.CollectionConfig) (*api.CollectionResource, error)
	PatchCollection(id string, patches *api.Patch) (*api.CollectionResource, error)
	DeleteCollection(id string) error

	// Provider operations
	CreateProvider(provider *api.ProviderResource) error
	GetProvider(id string) (*api.ProviderResource, error)
	GetProviders(filter *QueryFilter) (*QueryResults[api.ProviderResource], error)
	UpdateProvider(id string, providerConfig *api.ProviderConfig) (*api.ProviderResource, error)
	PatchProvider(id string, patches *api.Patch) (*api.ProviderResource, error)
	DeleteProvider(id string) error

	// Close the storage connection
	Close() error
}

Jump to

Keyboard shortcuts

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