Documentation
¶
Overview ¶
Package sql provides a SQL upstream implementation.
Index ¶
- type Tool
- func (t *Tool) Execute(ctx context.Context, req *tool.ExecutionRequest) (any, error)
- func (t *Tool) GetCacheConfig() *configv1.CacheConfig
- func (t *Tool) IsStreaming() bool
- func (t *Tool) MCPTool() *mcp.Tool
- func (t *Tool) StreamExecute(ctx context.Context, req *tool.ExecutionRequest) (<-chan any, error)
- func (t *Tool) Tool() *v1.Tool
- type Upstream
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 ¶
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 ¶
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 ¶
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 ¶
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.
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 ¶
func (u *Upstream) Register( ctx context.Context, serviceConfig *configv1.UpstreamServiceConfig, toolManager tool.ManagerInterface, _ prompt.ManagerInterface, _ resource.ManagerInterface, _ bool, ) (string, []*configv1.ToolDefinition, []*configv1.ResourceDefinition, error)
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 ¶
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.