server

package
v0.18.52 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: AGPL-3.0 Imports: 39 Imported by: 0

Documentation

Overview

Package server provides the HTTP API for Wadjet.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdminAPI

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

AdminAPI provides REST endpoints for runtime configuration management. All admin endpoints require the "admin" permission.

func NewAdminAPI

func NewAdminAPI(manager *config.Manager, provider *auth.Provider, logger *slog.Logger) *AdminAPI

NewAdminAPI creates an admin API handler.

func (*AdminAPI) RegisterRoutes

func (a *AdminAPI) RegisterRoutes(r chi.Router)

RegisterRoutes adds admin routes to the given router.

type AsyncQueryResponse

type AsyncQueryResponse struct {
	QueryID string `json:"query_id"`
	State   string `json:"state"`
	Plan    string `json:"plan,omitempty"`
}

AsyncQueryResponse is returned when a query is submitted asynchronously.

type Config

type Config struct {
	Addr                string
	Catalog             *catalog.Catalog
	Coordinator         *coordinator.Coordinator       // nil = local execution only
	DLQ                 *coordinator.DLQ               // nil = no DLQ (standalone mode)
	Auth                *auth.Authenticator            // nil = no authentication (static mode)
	Authz               *auth.Authorizer               // nil = no authorization (static mode)
	Policies            *auth.PolicySet                // nil = no cell-level policies (static mode)
	Provider            *auth.Provider                 // nil = use static Auth/Authz/Policies above
	Metrics             *metrics.Metrics               // nil = no metrics collection
	TLSConfig           *tls.Config                    // nil = plain HTTP
	MaxConnections      int                            // 0 = unlimited
	SlowQueryThreshold  time.Duration                  // 0 = disabled, log queries exceeding this
	ShutdownTimeout     time.Duration                  // graceful shutdown drain timeout (default 30s)
	QueryLimits         *config.QueryLimits            // global cost-based query limits (nil = unlimited)
	RoleLimits          map[string]*config.QueryLimits // per-role overrides (nil = use global)
	SortMergeJoinBytes  int64                          // local sort-merge-join gate (0 = disabled)
	LateMaterialization bool                           // view-column join output, deferred gather (default off)
}

Config holds server configuration.

type CreateTableColumn

type CreateTableColumn struct {
	Name     string `json:"name"`
	Type     string `json:"type"`
	Nullable *bool  `json:"nullable,omitempty"` // default true
}

CreateTableColumn defines a column in a REST table creation request.

type CreateTableRequest

type CreateTableRequest struct {
	Name          string              `json:"name"`
	Columns       []CreateTableColumn `json:"columns"`
	PartitionKeys []string            `json:"partition_keys,omitempty"`
}

CreateTableRequest is the request body for POST /v1/tables.

type GRPCConfig

type GRPCConfig struct {
	Addr           string
	Catalog        *catalog.Catalog
	Coord          *coordinator.Coordinator // nil = standalone
	DB             *wadjetdb.DB             // nil = distributed
	TLSConfig      *tls.Config              // nil = plain gRPC
	MaxConnections int                      // 0 = unlimited
	AuthProvider   *auth.Provider           // nil = no auth enforcement
}

GRPCConfig holds configuration for the gRPC server.

type GRPCServer

type GRPCServer struct {
	wadjetv1.UnimplementedWadjetServiceServer
	// contains filtered or unexported fields
}

GRPCServer implements the WadjetService gRPC API.

func NewGRPCServer

func NewGRPCServer(cfg GRPCConfig, logger *slog.Logger) *GRPCServer

NewGRPCServer creates a new gRPC server.

func (*GRPCServer) CancelQuery

CancelQuery cancels a running query.

func (*GRPCServer) CreateTable

CreateTable creates a new table.

func (*GRPCServer) DescribeTable

DescribeTable returns a table's schema.

func (*GRPCServer) DropTable

DropTable removes a table.

func (*GRPCServer) GetQueryStatus

GetQueryStatus returns the status of an async query.

func (*GRPCServer) ListTables

ListTables returns all table names.

func (*GRPCServer) Query

Query executes a SQL query and returns all results.

func (*GRPCServer) QueryStream

QueryStream executes a SQL query and streams result batches.

func (*GRPCServer) Shutdown

func (g *GRPCServer) Shutdown()

Shutdown gracefully stops the gRPC server.

func (*GRPCServer) Start

func (g *GRPCServer) Start() error

Start begins serving gRPC on the configured address.

func (*GRPCServer) SubmitQuery

SubmitQuery submits an async query (distributed mode only).

type OpsAPI

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

OpsAPI provides operational endpoints for monitoring and cleanup.

func NewOpsAPI

func NewOpsAPI(coord *coordinator.Coordinator) *OpsAPI

NewOpsAPI creates operational API endpoints.

func (*OpsAPI) RegisterRoutes

func (o *OpsAPI) RegisterRoutes(r chi.Router)

RegisterRoutes adds operational routes to the given router.

type QueryRequest

type QueryRequest struct {
	SQL string `json:"sql"`
}

QueryRequest is the request body for POST /v1/queries.

type QueryResponse

type QueryResponse struct {
	QueryID string           `json:"query_id"`
	Columns []string         `json:"columns"`
	Rows    []map[string]any `json:"rows"`
	// Values is the same rows POSITIONALLY, one slice per row aligned with
	// Columns. It is sent whenever two output columns publish ONE NAME, which
	// a JSON object cannot represent: `SELECT g + 1, g + 2, g + 3` is three
	// columns called `?column?` in PostgreSQL and here (#732), and `rows`
	// carries one key for the three of them. `columns` is always the full
	// positional list; a client that needs every value reads `values` when it
	// is present (round-1 review B1).
	Values [][]any    `json:"values,omitempty"`
	Stats  QueryStats `json:"stats"`
	Error  string     `json:"error,omitempty"`
}

QueryResponse is the response for POST /v1/queries.

type QueryStats

type QueryStats struct {
	Elapsed     string `json:"elapsed"`
	RowsScanned int64  `json:"rows_scanned"`
	Plan        string `json:"plan,omitempty"`
}

QueryStats contains execution statistics.

type QueryStatusResponse

type QueryStatusResponse struct {
	QueryID   string            `json:"query_id"`
	SQL       string            `json:"sql"`
	State     string            `json:"state"`
	Stages    []StageStatusView `json:"stages,omitempty"`
	Elapsed   string            `json:"elapsed"`
	TotalRows int64             `json:"total_rows"`
	Error     string            `json:"error,omitempty"`
}

QueryStatusResponse is returned when checking query status.

type Server

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

Server is the Wadjet HTTP API server.

func New

func New(cfg Config, logger *slog.Logger) *Server

New creates a new HTTP server.

func (*Server) Mux

func (s *Server) Mux() chi.Router

Mux returns the underlying chi router for registering additional routes (e.g. admin API).

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the server, draining in-flight requests.

func (*Server) Start

func (s *Server) Start() error

Start starts the HTTP server.

type StageStatusView

type StageStatusView struct {
	StageID     string `json:"stage_id"`
	Type        string `json:"type"`
	TotalTasks  int    `json:"total_tasks"`
	DoneTasks   int    `json:"done_tasks"`
	FailedTasks int    `json:"failed_tasks"`
}

StageStatusView is the JSON representation of a stage's progress.

Directories

Path Synopsis
Package mcp implements a Model Context Protocol (MCP) server for Wadjet.
Package mcp implements a Model Context Protocol (MCP) server for Wadjet.
Package pgwire implements the PostgreSQL v3 wire protocol frontend.
Package pgwire implements the PostgreSQL v3 wire protocol frontend.

Jump to

Keyboard shortcuts

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