extensions

package
v0.9.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdaptLegacyExtension

func AdaptLegacyExtension(ext LegacyEngineExtension) precompiles.Initializer

AdapterFunc is a function that adapts a LegacyEngineExtension to an InitializeFunc.

Types

type Connecter

type Connecter interface {
	Connect(ctx context.Context, target string, opts ...client.ClientOpt) (ExtensionClient, error)
}
var (
	// this can be overridden for testing
	ConnectFunc Connecter = extensionConnectFunc(client.NewExtensionClient)
)

type ExtensionClient

type ExtensionClient interface {
	CallMethod(execCtx *types.ExecutionContext, method string, args ...any) ([]any, error)
	Close() error
	Initialize(ctx context.Context, metadata map[string]string) (map[string]string, error)
	GetName(ctx context.Context) (string, error)
	ListMethods(ctx context.Context) ([]string, error)
}

type ExtensionInitializer

type ExtensionInitializer struct {
	Extension LegacyEngineExtension
}

func (*ExtensionInitializer) CreateInstance

func (e *ExtensionInitializer) CreateInstance(ctx context.Context, metadata map[string]string) (*Instance, error)

CreateInstance creates an instance of the extension with the given metadata.

type Instance

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

An instance is a single instance of an extension. Each Kuneiform schema that uses an extension will have its own instance. The instance is a way to encapsulate metadata. For example, the instance may contain the smart contract address for an ERC20 token that is used by the Kuneiform schema.

func (*Instance) Execute

func (i *Instance) Execute(ctx *precompiles.ProcedureContext, method string, args ...any) ([]any, error)

func (*Instance) Metadata

func (i *Instance) Metadata() map[string]string

type LegacyEngineExtension

type LegacyEngineExtension interface {
	// Initialize initializes the extension with the given metadata.
	// It is called each time a database is deployed that uses the extension,
	// or for each database that uses the extension when the engine starts.
	// If a database initializes an extension several times, it will be called
	// each times.
	// It should return the metadata that it wants to be returned on each
	// subsequent call from the extension.
	// If it returns an error, the database will fail to deploy.
	Initialize(ctx context.Context, metadata map[string]string) (map[string]string, error)
	// Execute executes the requested method of the extension.
	// It includes the metadata that was returned from the `Initialize` method.
	Execute(scope *precompiles.ProcedureContext, metadata map[string]string, method string, args ...any) ([]any, error)
}

LegacyEngineExtension is an extension that can be loaded into the engine. It can be used to extend the functionality of the engine.

type RemoteExtension

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

Remote Extension used for docker extensions defined and deployed remotely

func New

func New(url string) *RemoteExtension

New returns a placeholder for the RemoteExtension at a given url

func (*RemoteExtension) Connect

func (e *RemoteExtension) Connect(ctx context.Context) error

Connect connects to the given extension, and attempts to configure it with the given config. If the extension is not available, an error is returned.

func (*RemoteExtension) Execute

func (e *RemoteExtension) Execute(ctx *precompiles.ProcedureContext, metadata map[string]string, method string, args ...any) ([]any, error)

Execute executes the requested method of an extension. If the method is not supported, an error is returned.

func (*RemoteExtension) Initialize

func (e *RemoteExtension) Initialize(ctx context.Context, metadata map[string]string) (map[string]string, error)

Initialize initializes based on the given metadata and returns the updated metadata

func (*RemoteExtension) Name

func (e *RemoteExtension) Name() string

Jump to

Keyboard shortcuts

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