v1

package
v0.0.79 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: Apache-2.0 Imports: 5 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 Context added in v0.0.77

type Context struct {
	Ingest *interfaces.Result
}

Context encapsulates the context passed to all context function calls

type ContextKey added in v0.0.77

type ContextKey struct {
}

ContextKey type to store/retrieve the context

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(ctx context.Context, args any) (any, error)
	// GetArgsSchema returns the schema of the arguments.
	GetArgsSchema() any
}

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