cloudquery

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package cloudquery is the orchestration layer for SafeDep Cloud's SQL query service. It owns the gRPC client wiring, the proto-to-Go boundary translation, and the value types that command code consumes.

Command packages depend on the small interfaces declared here, not on the gRPC types or proto messages. Tests substitute fakes for the interfaces; production wiring uses Service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column added in v0.1.5

type Column struct {
	Name string
	Type string
}

Column is one result column with its server-declared type. Type is the ColumnType name with the COLUMN_TYPE_ prefix stripped (e.g. STRING, INT).

type EnumValue added in v0.1.5

type EnumValue struct {
	Name   string
	Number int32
}

EnumValue is one server-advertised value for an enum-typed column.

type ExecInput

type ExecInput struct {
	SQL       string
	PageSize  int
	PageToken string
}

ExecInput is the user-facing payload for a SQL execution. Validation is the caller's responsibility: orchestration trusts what it receives. PageToken empty means "first page"; non-empty resumes a prior response.

type ExecResult

type ExecResult struct {
	Columns     []Column
	Rows        []Row
	NextPage    string
	GeneratedAt time.Time
	Stats       Stats
}

ExecResult is the materialised query response in a presentation-friendly shape. Columns is the ordered set of columns the server returned.

type ExecRunner

type ExecRunner interface {
	Exec(ctx context.Context, in ExecInput) (*ExecResult, error)
}

ExecRunner is the contract a query executor satisfies.

type JoinEdge added in v0.1.5

type JoinEdge struct {
	From        string
	To          string
	Cardinality string
}

JoinEdge is an advertised join relationship between two tables. Cardinality is the server string verbatim (one_to_one, one_to_many, many_to_one).

type Row

type Row map[string]any

Row is one decoded row. Values are typed natives (string, float64, bool, nil). Unknown structpb kinds are rendered as their string form so callers do not have to handle proto types directly.

type Schema

type Schema struct {
	Tables []SchemaTable
	Edges  []JoinEdge
	Usage  Usage
}

Schema is the full SQL schema served by the control plane.

type SchemaColumn

type SchemaColumn struct {
	Name         string
	Type         string
	Description  string
	Selectable   bool
	Filterable   bool
	Groupable    bool
	Aggregatable bool
	Indexed      bool
	ReferenceURL string
	EnumValues   []EnumValue
}

SchemaColumn describes one column inside a table.

type SchemaFetcher

type SchemaFetcher interface {
	Schema(ctx context.Context) (*Schema, error)
}

SchemaFetcher is the contract a schema reader satisfies.

type SchemaTable

type SchemaTable struct {
	Name              string
	Description       string
	Columns           []SchemaColumn
	TimeColumn        string
	TimeWindowMaxDays int64
}

SchemaTable describes one queryable table.

type Service

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

Service is the production implementation backed by a control-plane gRPC connection. Command code accepts the small interfaces in this file (ExecRunner, SchemaFetcher) so unit tests can pass stubs.

func NewService

func NewService(conn *grpc.ClientConn) *Service

NewService wraps a control-plane gRPC connection in a Service.

func (*Service) Exec

func (s *Service) Exec(ctx context.Context, in ExecInput) (*ExecResult, error)

Exec runs a single SQL statement against the control plane and returns the decoded rows. PageSize <= 0 leaves it unset so the server applies its default. PageToken empty means "first page".

func (*Service) Schema

func (s *Service) Schema(ctx context.Context) (*Schema, error)

Schema fetches the SQL schema metadata served by the control plane.

type Stats added in v0.1.5

type Stats struct {
	EstimatedCost float64
	EstimatedRows int64
	ElapsedMs     int64
}

Stats is the planner-reported execution summary for a query response.

type Usage added in v0.1.5

type Usage struct {
	Rules          []string
	ExampleQueries []string
}

Usage is the server's grammar guidance: rules to follow and example queries.

Jump to

Keyboard shortcuts

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