context

package
v0.5.13 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BucketFsContext

type BucketFsContext interface {
	// ResolvePath returns an absolute path for the given filename in BucketFS.
	ResolvePath(fileName string) string
}

BucketFsContext allows extensions to interact with BucketFS.

[impl -> dsn~extension-context-bucketfs~1].

type BucketFsContextMock added in v0.5.3

type BucketFsContextMock struct {
	mock.Mock
}

func CreateBucketFsContextMock added in v0.5.3

func CreateBucketFsContextMock() *BucketFsContextMock

func (*BucketFsContextMock) ResolvePath added in v0.5.3

func (mock *BucketFsContextMock) ResolvePath(fileName string) string

func (*BucketFsContextMock) SimulateResolvePath added in v0.5.3

func (mock *BucketFsContextMock) SimulateResolvePath(fileName string, result string)

func (*BucketFsContextMock) SimulateResolvePathPanics added in v0.5.3

func (mock *BucketFsContextMock) SimulateResolvePathPanics(fileName string, panicMessage string)

type ContextSqlClient

type ContextSqlClient interface {
	// Execute runs a query that does not return rows, e.g. INSERT or UPDATE.
	Execute(query string, args ...any)

	// Query runs a query that returns rows, typically a SELECT.
	Query(query string, args ...any) backend.QueryResult
}

type ExtensionContext

type ExtensionContext struct {
	ExtensionSchemaName string           `json:"extensionSchemaName"` // Name of the schema where EM creates all database objects (e.g. scripts or virtual schemas)
	SqlClient           ContextSqlClient `json:"sqlClient"`           // Allows extensions to execute SQL queries and statements
	BucketFs            BucketFsContext  `json:"bucketFs"`            // Allows extensions to interact with BucketFS
	Metadata            MetadataContext  `json:"metadata"`            // Allows extensions to read Exasol metadata tables
}

Instances of type ExtensionContext are passed to an extension so that extension can

  • retrieve context information like the extension schema name (field ExtensionSchemaName)
  • execute SQL queries against the database using a [SqlClient]
  • or resolve files in BucketFS using [BucketFs]

func CreateContext

func CreateContext(txCtx *transaction.TransactionContext, extensionSchemaName string) *ExtensionContext

func CreateContextWithClient

func CreateContextWithClient(extensionSchemaName string, txCtx *transaction.TransactionContext,
	client backend.SimpleSQLClient, bucketFsContext BucketFsContext, metadataReader exaMetadata.ExaMetadataReader) *ExtensionContext

type MetadataContext

type MetadataContext interface {
	// Get a row from the SYS.EXA_ALL_SCRIPTS table for the given schema and script name.
	//
	// Returns `nil` when no script exists with the given name.
	// The JS runtime will convert `nil` to `null` in JavaScript code, so extensions can
	// check if a script was found by testing the result with `=== null`.
	GetScriptByName(name string) *exaMetadata.ExaScriptRow
}

MetadataContext contains methods for reading Exasol metadata tables.

Jump to

Keyboard shortcuts

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