cloudsql

package
v1.5.68 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package cloudsql implements Hanzo Cloud SQL — a serverless PostgreSQL integration plugin for Hanzo Base. It manages per-base database provisioning, connection routing, and proxies schema management requests to postgres-meta.

Hanzo Cloud SQL is the scalable, per-org PostgreSQL layer backed by Neon's open-source storage/compute separation. "Hanzo SQL" (sql.hanzo.svc) is the shared single-instance PostgreSQL; "Hanzo Cloud SQL" is the auto-scaling, per-base serverless variant.

Example:

cloudsql.MustRegister(app, cloudsql.Config{
	MetaURL:        "http://base-meta.hanzo.svc:8080",
	ComputeHost:    "cloud-sql.hanzo.svc",
	ComputePort:    5432,
	DefaultPGUser:  "hanzo",
	DefaultPGPass:  "from-kms",
})

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustRegister

func MustRegister(app core.App, config Config)

MustRegister registers the Cloud SQL plugin and panics on failure.

func Register

func Register(app core.App, config Config) error

Register registers the Cloud SQL plugin to the provided app instance. A Config that is not Enabled registers nothing, so /v1/cloud-sql and /v1/meta are addresses the process does not answer at.

Types

type Config

type Config struct {
	// Enabled decides whether the plugin registers at all. A zero-value Config
	// is disabled and callers opt in, the way bootnode and calendar do.
	//
	// Every address this plugin publishes hands out, or acts on, the string
	// that opens a database — and that string carries the PostgreSQL password
	// the plugin is configured with. So the routes exist where a deployment
	// configured Cloud SQL, and nowhere else.
	Enabled bool

	// MetaURL is the URL of the postgres-meta service.
	MetaURL string

	// ComputeHost is the hostname of the Cloud SQL compute endpoint.
	ComputeHost string

	// ComputePort is the port for Cloud SQL compute (default: 5432).
	ComputePort int

	// DefaultPGUser is the PostgreSQL admin user (default: "hanzo").
	DefaultPGUser string

	// DefaultPGPass is the PostgreSQL admin password.
	DefaultPGPass string

	// ProxyHost is the Cloud SQL proxy hostname for client connections.
	ProxyHost string

	// ProxyPort is the Cloud SQL proxy port for client connections.
	ProxyPort int
}

Config defines the configuration for the Cloud SQL plugin.

func ConfigFromEnv added in v1.5.67

func ConfigFromEnv() Config

ConfigFromEnv reads CLOUD_SQL_ENABLED and the Cloud SQL upstream settings.

type OrgDatabase added in v1.5.24

type OrgDatabase struct {
	OrgID        string `json:"orgId"`
	DatabaseName string `json:"databaseName"`
	Host         string `json:"host"`
	Port         int    `json:"port"`
	User         string `json:"user"`
	Password     string `json:"password"`
	SSLMode      string `json:"sslMode"`
}

OrgDatabase holds Cloud SQL database info for a base.

func (*OrgDatabase) ConnectionString added in v1.5.24

func (t *OrgDatabase) ConnectionString() string

ConnectionString returns a PostgreSQL connection string.

A database that states no mode gets require, and this is the one place that decides it. A mode written beside this one can disagree with it, so nothing writes a mode a deployment did not choose.

Jump to

Keyboard shortcuts

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