sql

package
v0.0.0-...-5b49586 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package sql provides a SQL upstream implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Tool

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

Tool implements the Tool interface for a tool that executes a SQL query.

Summary: Represents a Tool.

func NewTool

func NewTool(t *v1.Tool, db *sql.DB, callDef *configv1.SqlCallDefinition, policies []*configv1.CallPolicy, callID string) *Tool

NewTool creates a new SQL Tool.

Parameters:

  • t (*v1.Tool): The parameter.
  • db (*sql.DB): The parameter.
  • callDef (*configv1.SqlCallDefinition): The parameter.
  • policies ([]*configv1.CallPolicy): The parameter.
  • callID (string): The parameter.

Returns:

  • *Tool: The result.

Side Effects:

  • None.

Summary: Initializes NewTool operation.

Parameters:

  • TODO: Document parameters.

Returns:

  • TODO: Document returns.

Errors:

  • TODO: Document errors.

Side Effects:

  • None.

func (*Tool) Execute

func (t *Tool) Execute(ctx context.Context, req *tool.ExecutionRequest) (any, error)

Execute executes the SQL tool with the provided request.

Summary: Executes the SQL query with the given inputs.

Parameters:

  • ctx (context.Context): The context for the request.
  • req (*tool.ExecutionRequest): The execution request containing parameters.

Returns:

  • any: The query results (a list of row maps).
  • error: An error if execution fails.

Errors:

  • Returns an error if policy evaluation fails or blocks execution.
  • Returns an error if input unmarshalling fails.
  • Returns an error if the database query fails.

Side Effects:

  • Executes a query on the database.

func (*Tool) GetCacheConfig

func (t *Tool) GetCacheConfig() *configv1.CacheConfig

GetCacheConfig returns the cache configuration for the tool.

Returns:

  • *configv1.CacheConfig: The result.

Side Effects:

  • None.

Summary: Retrieves GetCacheConfig operation.

Parameters:

  • TODO: Document parameters.

Returns:

  • TODO: Document returns.

Errors:

  • TODO: Document errors.

Side Effects:

  • None.

func (*Tool) IsStreaming

func (t *Tool) IsStreaming() bool

Execute runs the SQL query with the provided inputs.

Parameters:

  • ctx (context.Context): The context for the request.
  • req (*tool.ExecutionRequest): The parameter.

Returns:

  • any: The result.
  • error: An error if the operation fails.

Errors:

  • Returns an error if ...

Side Effects:

  • None.

Summary: Executes Execute operation.

Parameters:

  • TODO: Document parameters.

Returns:

  • TODO: Document returns.

Errors:

  • TODO: Document errors.

Side Effects:

  • None.

IsStreaming returns true if the tool supports streaming.

Summary: Checks if the tool supports streaming execution.

Returns:

  • bool: True if streaming is supported.

func (*Tool) MCPTool

func (t *Tool) MCPTool() *mcp.Tool

MCPTool returns the MCP tool definition.

Returns:

  • *mcp.Tool: The result.

Side Effects:

  • None.

Summary: Executes MCPTool operation.

Parameters:

  • TODO: Document parameters.

Returns:

  • TODO: Document returns.

Errors:

  • TODO: Document errors.

Side Effects:

  • None.

func (*Tool) StreamExecute

func (t *Tool) StreamExecute(ctx context.Context, req *tool.ExecutionRequest) (<-chan any, error)

StreamExecute executes the tool in streaming mode.

Summary: Executes the tool in streaming mode.

Parameters:

  • ctx: context.Context. The context for the request.
  • req: *ExecutionRequest. The request object containing parameters.

Returns:

  • <-chan any: A channel that emits streaming results.
  • error: An error if the operation fails or streaming is not supported.

func (*Tool) Tool

func (t *Tool) Tool() *v1.Tool

Tool returns the protobuf definition of the tool.

Returns:

  • *v1.Tool: The result.

Side Effects:

  • None.

Summary: Executes Tool operation.

Parameters:

  • TODO: Document parameters.

Returns:

  • TODO: Document returns.

Errors:

  • TODO: Document errors.

Side Effects:

  • None.

type Upstream

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

Upstream implements the upstream.Upstream interface for SQL databases.

Summary: Represents a Upstream.

func NewUpstream

func NewUpstream() *Upstream

NewUpstream creates a new SQL upstream.

Returns:

  • *Upstream: The result.

Side Effects:

  • None.

Summary: Initializes NewUpstream operation.

Parameters:

  • TODO: Document parameters.

Returns:

  • TODO: Document returns.

Errors:

  • TODO: Document errors.

Side Effects:

  • None.

func (*Upstream) Register

Register discovers and registers tools from the SQL configuration. ctx is the context for the request. serviceConfig is the serviceConfig. toolManager is the toolManager. _ is an unused parameter. _ is an unused parameter. _ is an unused parameter. Returns the result. Returns the result. Returns the result. Returns an error if the operation fails.

Parameters:

  • ctx (context.Context): The context for the request.
  • serviceConfig (*configv1.UpstreamServiceConfig): The serviceConfig parameter.
  • toolManager (tool.ManagerInterface): The toolManager parameter.
  • _ (prompt.ManagerInterface): The _ parameter.
  • _ (resource.ManagerInterface): The _ parameter.
  • _ (bool): The _ parameter.

Returns:

  • string: The resulting string.
  • []*configv1.ToolDefinition: The resulting []*configv1.ToolDefinition.
  • []*configv1.ResourceDefinition: The resulting []*configv1.ResourceDefinition.
  • error: An error if the operation fails.

Errors:

  • Returns an error if the operation fails or is invalid.

Side Effects:

  • None

Summary: Executes Register operation.

Parameters:

  • TODO: Document parameters.

Returns:

  • TODO: Document returns.

Errors:

  • TODO: Document errors.

Side Effects:

  • None.

func (*Upstream) Shutdown

func (u *Upstream) Shutdown(_ context.Context) error

Shutdown closes the database connection.

Parameters:

  • _ (context.Context): The parameter.

Returns:

  • error: An error if the operation fails.

Errors:

  • Returns an error if ...

Side Effects:

  • None.

Summary: Executes Shutdown operation.

Parameters:

  • TODO: Document parameters.

Returns:

  • TODO: Document returns.

Errors:

  • TODO: Document errors.

Side Effects:

  • None.

Jump to

Keyboard shortcuts

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