v1

package
v0.0.76 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package v1 provides the interfaces and types for the data sources.

Index

Constants

View Source
const (
	// DataSourceDriverRest is the driver type for a REST data source.
	DataSourceDriverRest = "rest"
)

Variables

View Source
var (
	// ErrDuplicateDataSourceFuncKey is the error returned when a data source
	// function key is already registered.
	ErrDuplicateDataSourceFuncKey = errors.New("duplicate data source function key")
)

Functions

This section is empty.

Types

type DataSource

type DataSource interface {
	// GetFuncs returns the functions that the data source provides.
	GetFuncs() map[DataSourceFuncKey]DataSourceFuncDef
}

DataSource is the interface that a data source must implement. It implements several functions that will be used by the engine to interact with external systems. These get taken into used by the Evaluator. Moreover, a data source must be able to validate an update to itself.

type DataSourceFuncDef

type DataSourceFuncDef interface {
	// ValidateArgs validates the arguments of the function.
	ValidateArgs(obj any) error
	// ValidateUpdate validates the update to the data source.
	// The data source implementation should respect the update and return an error
	// if the update is invalid.
	ValidateUpdate(obj any) error
	// Call calls the function with the given arguments.
	// It is the responsibility of the data source implementation to handle the call.
	// It is also the responsibility of the caller to validate the arguments
	// before calling the function.
	Call(args any) (any, error)
}

DataSourceFuncDef is the definition of a data source function. It contains the key that uniquely identifies the function and the arguments that the function can take.

type DataSourceFuncKey

type DataSourceFuncKey string

DataSourceFuncKey is the key that uniquely identifies a data source function.

func (DataSourceFuncKey) String

func (k DataSourceFuncKey) String() string

String returns the string representation of the data source function key.

type DataSourceRegistry

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

DataSourceRegistry is the interface that a data source registry must implement. It provides methods to register a data source and get all functions that data sources provide globally.

func NewDataSourceRegistry

func NewDataSourceRegistry() *DataSourceRegistry

NewDataSourceRegistry creates a new data source registry.

func (*DataSourceRegistry) GetFuncs

GetFuncs returns all functions that data sources provide globally.

func (*DataSourceRegistry) RegisterDataSource

func (reg *DataSourceRegistry) RegisterDataSource(name string, ds DataSource) (err error)

RegisterDataSource registers a data source with the registry. Note that the name of the data source must be unique.

Directories

Path Synopsis
Package mock_v1 is a generated GoMock package.
Package mock_v1 is a generated GoMock package.

Jump to

Keyboard shortcuts

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