Documentation
¶
Index ¶
- Constants
- Variables
- func CanHaveBranches(service api.Service) bool
- func CheckReadOnly(cfg *config.Config, tag api.EnvironmentTag) error
- func CheckReadOnlyByServiceID(ctx context.Context, cfg *config.Config, ...) error
- func CheckReady(status api.DeployStatus) error
- func CountBranches(ctx context.Context, client api.ClientWithResponsesInterface, ...) (int, error)
- func EnvAPIKey() (publicKey, secretKey string, ok bool)
- func ExitWithCode(code int, err error) error
- func ExitWithErrorFromStatusCode(statusCode int, err error) error
- func FetchServiceLogs(ctx context.Context, args FetchServiceLogsArgs) ([]api.ServiceLogEntry, error)
- func FormatBranchCount(n int) string
- func FormatCPUCores(cpuMillis int) string
- func FormatSchema(schema *DatabaseSchema) string
- func GetPassword(cfg *config.Config, target PasswordTarget, role string) (string, error)
- func GetService(ctx context.Context, client api.ClientWithResponsesInterface, ...) (*api.Service, error)
- func IdentifyOAuthUser(ctx context.Context, cfg *config.Config, ...)
- func IsReadReplica(service api.Service) bool
- func IsValidAddon(addon string) bool
- func ListBranches(ctx context.Context, client api.ClientWithResponsesInterface, ...) ([]api.Branch, error)
- func NewAPIClient(ctx context.Context, cfg *config.Config) (*api.ClientWithResponses, string, error)
- func ReplicaPoolerWarning(target *ConnectionTarget, pooled bool) string
- func ResolveBranch(ctx context.Context, client api.ClientWithResponsesInterface, ...) (*api.Branch, error)
- func ServiceEnvironmentTag(service api.Service) api.EnvironmentTag
- func ValidAddons() []string
- func ValidPlatforms() []string
- func ValidateAPIKey(ctx context.Context, cfg *config.Config, ...) (*api.AuthInfo, error)
- func ValidateAddons(addons []string) ([]string, error)
- func WaitForBranch(ctx context.Context, args WaitForBranchArgs) error
- func WaitForService(ctx context.Context, args WaitForServiceArgs) error
- type App
- func (a *App) GetAll() (*config.Config, api.ClientWithResponsesInterface, string, error)
- func (a *App) GetClient() (api.ClientWithResponsesInterface, string, error)
- func (a *App) GetConfig() *config.Config
- func (a *App) Load(ctx context.Context) (*config.Config, api.ClientWithResponsesInterface, string, error)
- func (a *App) SetClient(client api.ClientWithResponsesInterface, projectID string)
- func (a *App) SetClientFactory(f ClientFactory)
- func (a *App) SetFlags(flags *pflag.FlagSet)
- func (a *App) TryGetAll() (*config.Config, api.ClientWithResponsesInterface, string)
- type CPUMemoryConfig
- type CPUMemoryConfigs
- func (c CPUMemoryConfigs) Parse(cpuMemoryStr string) (string, string, error)
- func (c CPUMemoryConfigs) String() string
- func (c CPUMemoryConfigs) Strings() []string
- func (c CPUMemoryConfigs) ValidateAndNormalize(cpuMillis, memoryGBs string) (*CPUMemoryConfig, error)
- func (c CPUMemoryConfigs) WithoutShared() CPUMemoryConfigs
- type CheckConstraint
- type ClientFactory
- type Column
- type ConnectionDetails
- type ConnectionDetailsOptions
- type ConnectionTarget
- func NewBranchConnectionTarget(branch api.Branch) *ConnectionTarget
- func NewConnectionTarget(ctx context.Context, client api.ClientWithResponsesInterface, projectID string, ...) (*ConnectionTarget, error)
- func NewReplicaConnectionTarget(replica api.ReadReplicaSet, credentials CredentialOwner) *ConnectionTarget
- func NewServiceConnectionTarget(service api.Service) *ConnectionTarget
- func ResolveConnectionTarget(ctx context.Context, client api.ClientWithResponsesInterface, ...) (*ConnectionTarget, error)
- func ResolveConnectionTargetByID(ctx context.Context, client api.ClientWithResponsesInterface, ...) (*ConnectionTarget, error)
- type ConstraintType
- type ContinuousAggregateInfo
- type CredentialOwner
- type DatabaseSchema
- type EnumSchema
- type ExclusionConstraint
- type ExecuteQueryArgs
- type ExitCodeError
- type Extension
- type FetchServiceLogsArgs
- type FetchServiceSchemaArgs
- type ForeignTableInfo
- type HypertableInfo
- type IndexSchema
- type KeyringStorage
- func (k *KeyringStorage) Get(target PasswordTarget, role string) (string, error)
- func (k *KeyringStorage) GetStorageResult(err error, password string) PasswordStorageResult
- func (k *KeyringStorage) Remove(target PasswordTarget, role string) error
- func (k *KeyringStorage) Save(target PasswordTarget, password string, role string) error
- type NamespacedSchema
- type NoStorage
- func (n *NoStorage) Get(target PasswordTarget, role string) (string, error)
- func (n *NoStorage) GetStorageResult(err error, password string) PasswordStorageResult
- func (n *NoStorage) Remove(target PasswordTarget, role string) error
- func (n *NoStorage) Save(target PasswordTarget, password string, role string) error
- type PartitionInfo
- type PasswordStorage
- type PasswordStorageResult
- type PasswordTarget
- type PgpassStorage
- func (p *PgpassStorage) Get(target PasswordTarget, role string) (string, error)
- func (p *PgpassStorage) GetStorageResult(err error, password string) PasswordStorageResult
- func (p *PgpassStorage) Remove(target PasswordTarget, role string) error
- func (p *PgpassStorage) Save(target PasswordTarget, password string, role string) error
- type QueryResult
- type Resolved
- type ResultSet
- type Routine
- type RoutineType
- type SchemaIdent
- type SchemaNotFoundError
- type Spinner
- type SpinnerArgs
- type TableColumnSchema
- type TableConstraint
- type TableSchema
- type TargetKind
- type TriggerSchema
- type ViewColumnSchema
- type ViewSchema
- type WaitForBranchArgs
- type WaitForServiceArgs
Constants ¶
const ( ExitSuccess = 0 // Success ExitGeneralError = 1 // General error ExitTimeout = 2 // Operation timeout (wait-timeout exceeded) or connection timeout ExitInvalidParameters = 3 // Invalid parameters ExitAuthenticationError = 4 // Authentication error ExitPermissionDenied = 5 // Permission denied ExitServiceNotFound = 6 // Service not found ExitUpdateAvailable = 7 // Update available )
Exit codes as defined in the CLI specification
const ( AddonNone = "none" // Special value for no add-ons AddonTimeSeries = "time-series" )
Addon constants - these match the ServiceCreateAddons from the API
const ( PlatformStandard = "standard" PlatformFluid = "fluid" )
Platform constants - the API's ServicePlatform values, lowercased to match the other flag and parameter values users type
const BranchEnvironmentTag = api.EnvironmentTagDEV
BranchEnvironmentTag is the tag every branch is judged by. Branches have no environment of their own and always count as DEV, so read_only=prod leaves them writable even when their parent is tagged PROD: branching production to work against it safely is the main use case. read_only=all still blocks them.
Variables ¶
var ( // ErrPaused is returned for a paused (or pausing) service. ErrPaused = errors.New("service is paused") // ErrNotReady is returned for a service that isn't accepting connections // (provisioning, resuming, upgrading, deleting, etc.). ErrNotReady = errors.New("service is not ready") )
var ErrReadOnly = errors.New("this operation is not allowed in read-only mode")
ErrReadOnly is returned when read_only=all blocks a destructive operation.
var ErrReadOnlyProd = errors.New(`this operation is not allowed on services tagged PROD while read_only is set to "prod"`)
ErrReadOnlyProd is returned when read_only=prod blocks a destructive operation on a service tagged PROD.
var ExecuteQuery = func(ctx context.Context, cfg *config.Config, target *ConnectionTarget, args ExecuteQueryArgs) (*QueryResult, error) { if err := target.CheckReady(); err != nil { return nil, err } details, err := target.Details(cfg, ConnectionDetailsOptions{ Pooled: args.Pooled, Role: args.Role, WithPassword: true, ReadOnly: args.ReadOnly, }) if err != nil { return nil, err } connConfig, err := pgx.ParseConfig(details.String()) if err != nil { return nil, fmt.Errorf("failed to parse connection string: %w", err) } if len(args.Parameters) > 0 { connConfig.DefaultQueryExecMode = pgx.QueryExecModeExec } else { connConfig.DefaultQueryExecMode = pgx.QueryExecModeSimpleProtocol } conn, err := pgx.ConnectConfig(ctx, connConfig) if err != nil { return nil, fmt.Errorf("failed to connect to database: %w", err) } defer conn.Close(context.Background()) startTime := time.Now() batch := &pgx.Batch{} batch.Queue(args.Query, util.ConvertSliceToAny(args.Parameters)...) br := conn.SendBatch(ctx, batch) defer br.Close() // A nil budget means unlimited; processResultSet decrements it in place so // the cap spans every result set in the batch. var remainingBytes *int if args.MaxBytes > 0 { remainingBytes = &args.MaxBytes } resultSets := make([]ResultSet, 0) truncated := false for { rows, err := br.Query() if err != nil { if err.Error() == "no more results in batch" { break } return nil, err } result, err := processResultSet(conn, rows, args.MaxRows, remainingBytes) if err != nil { return nil, err } resultSets = append(resultSets, result) if result.Truncated { truncated = true break } } if err := br.Close(); err != nil { return nil, err } return &QueryResult{ ResultSets: resultSets, ExecutionTime: time.Since(startTime), Truncated: truncated, }, nil }
ExecuteQuery runs a query against a service (or one of its read replicas) and collects every result set it produces. It is the shared entry point for the `tiger db query` CLI command and the db_query MCP tool.
Multi-statement queries (semicolon-separated) are supported when no parameters are given; with parameters, only a single statement is.
Declared as a var so tests can replace it with a stub that doesn't require a real database connection.
var FetchExtensions = func(ctx context.Context, cfg *config.Config, target *ConnectionTarget, role string) ([]Extension, error) { conn, err := connectReadOnly(ctx, cfg, target, role, false) if err != nil { return nil, err } defer conn.Close(context.Background()) rows, err := conn.Query(ctx, extensionsQuery) if err != nil { return nil, fmt.Errorf("failed to fetch extensions: %w", err) } extensions, err := pgx.CollectRows(rows, func(row pgx.CollectableRow) (Extension, error) { var ext Extension err := row.Scan(&ext.Name, &ext.Version, &ext.Schema, &ext.Description) return ext, err }) if err != nil { return nil, fmt.Errorf("failed to fetch extensions: %w", err) } return extensions, nil }
FetchExtensions lists the extensions installed in the target's database, sorted by name. It is a variable so tests can replace it and run without a real database.
var FetchServiceSchema = func(ctx context.Context, cfg *config.Config, target *ConnectionTarget, args FetchServiceSchemaArgs) (*DatabaseSchema, error) { conn, err := connectReadOnly(ctx, cfg, target, args.Role, args.Pooled) if err != nil { return nil, err } defer conn.Close(context.Background()) ident := SchemaIdent{ ID: target.ID, Name: target.Name, } return fetchSchemaFromConn(ctx, conn, ident, args) }
FetchServiceSchema opens a read-only connection to the target (a primary service or one of its read replicas) and introspects its schema. It is the shared entry point for the `tiger db schema` CLI command and the db_schema MCP tool.
The connection is forced read-only: introspection only issues SELECTs, so this is always safe and guards against accidental writes.
It is a var so tests can stub the connection out and reach the callers' success paths, which are otherwise only reachable against a live database.
var GenerateSecurePassword = func(length int) (string, error) { bytes := make([]byte, length) if _, err := rand.Read(bytes); err != nil { return "", fmt.Errorf("failed to generate random password: %w", err) } encodedPassword := base64.URLEncoding.EncodeToString(bytes) if len(encodedPassword) > length { encodedPassword = encodedPassword[:length] } return encodedPassword, nil }
GenerateSecurePassword generates a cryptographically secure random password. It is a var so tests can pin the password and assert the request that carries it exactly.
var GenerateServiceName = func() string { return fmt.Sprintf("db-%d", 10000+rand.Intn(90000)) }
GenerateServiceName matches the front-end logic for generating a random service name. It is a var so tests can pin the name and assert the request that carries it exactly.
var ( // GetStoredCredentials loads the stored credentials (PAT or OAuth) from the // keyring or fallback file. It's a package var so tests can override it to // inject credentials of either shape. GetStoredCredentials = func(cfg *config.Config) (*config.Credentials, error) { return cfg.GetStoredCredentials() } )
var LegacyMetrics = []string{
"timescale_cloud_system_cpu_total_millicores",
"timescale_cloud_system_cpu_usage_millicores",
"timescale_cloud_system_disk_io_read_bytes",
"timescale_cloud_system_disk_io_read_ops",
"timescale_cloud_system_disk_io_total_bytes",
"timescale_cloud_system_disk_io_total_ops",
"timescale_cloud_system_disk_io_write_bytes",
"timescale_cloud_system_disk_io_write_ops",
"timescale_cloud_system_disk_usage_bytes",
"timescale_cloud_system_memory_total_bytes",
"timescale_cloud_system_memory_usage_bytes",
}
LegacyMetrics lists the resource metrics that predate the metrics registry. Requests with fn or group_by against one of these are rejected with INVALID_REQUEST, and service_metrics_details returns no type, default aggregation, description, or labels for them — just the name.
Functions ¶
func CanHaveBranches ¶ added in v0.27.0
CanHaveBranches reports whether service can have branches, so callers can skip listing them for services that never do. Only fluid services can be branched.
func CheckReadOnly ¶
func CheckReadOnly(cfg *config.Config, tag api.EnvironmentTag) error
CheckReadOnly returns an error when read-only mode blocks writes to a service with the given environment tag. Use CheckReadOnlyByServiceID when only the ID is known; where a boolean is wanted, compare the result against nil.
func CheckReadOnlyByServiceID ¶ added in v0.23.0
func CheckReadOnlyByServiceID(ctx context.Context, cfg *config.Config, client api.ClientWithResponsesInterface, projectID, serviceID string) error
CheckReadOnlyByServiceID is CheckReadOnly for a caller that has only the service's ID, fetching the service to read its tag. A failed fetch is a refusal: we can't tell whether the service is PROD.
Only prod's verdict depends on the tag, so only prod pays for the lookup.
func CheckReady ¶ added in v0.27.0
func CheckReady(status api.DeployStatus) error
CheckReady returns nil only for a READY status, ErrPaused for PAUSED/PAUSING, and ErrNotReady for every other (or unknown) status.
func CountBranches ¶ added in v0.27.0
func CountBranches(ctx context.Context, client api.ClientWithResponsesInterface, projectID, serviceID string) (int, error)
CountBranches returns how many branches serviceID has.
func EnvAPIKey ¶
EnvAPIKey returns the API key credentials from the environment and whether any were set. Env credentials take precedence over the stored login; use this instead of reading the env vars directly.
func ExitWithCode ¶
ExitWithCode returns an error that will cause the program to exit with the specified code
func ExitWithErrorFromStatusCode ¶
ExitWithErrorFromStatusCode maps HTTP status codes to CLI exit codes
func FetchServiceLogs ¶
func FetchServiceLogs(ctx context.Context, args FetchServiceLogsArgs) ([]api.ServiceLogEntry, error)
FetchServiceLogs fetches service logs with cursor-based pagination up to the specified tail limit. Returns entries in ascending order by timestamp (oldest first, newest last).
func FormatBranchCount ¶ added in v0.27.0
FormatBranchCount phrases a number of branches, as "1 branch" or "2 branches".
func FormatCPUCores ¶ added in v0.27.0
FormatCPUCores formats millicores as a number of cores with as many decimal places as it needs (e.g. "0.25", "0.5", "2").
func FormatSchema ¶
func FormatSchema(schema *DatabaseSchema) string
FormatSchema formats a DatabaseSchema into a human-readable string, grouping objects under a SCHEMA: <name> header for each namespace. When includeDefinitions is false, the verbose object source bodies (view defining SELECTs and function/procedure bodies) are omitted, leaving just the structural summary (columns, constraints, indexes, signatures, etc.). When includeComments is true, object comments (COMMENT ON text) render as "-- " annotation lines under each object header and inline after columns.
func GetPassword ¶
GetPassword fetches the password stored for the target from the configured password storage mechanism. It returns an error if it fails to find the password.
func GetService ¶
func GetService(ctx context.Context, client api.ClientWithResponsesInterface, projectID, id string) (*api.Service, error)
GetService fetches a single service by ID. The API resolves both primary service IDs and read replica set IDs here; a read replica comes back as a service whose endpoint is the replica's and whose ForkedFrom links to its parent.
func IdentifyOAuthUser ¶
func IdentifyOAuthUser(ctx context.Context, cfg *config.Config, client api.ClientWithResponsesInterface, projectID string)
IdentifyOAuthUser sends an analytics Identify for an OAuth (PKCE) login, using the token-authenticated client built during login. It fetches the caller's identity via /auth/info. Best-effort.
func IsReadReplica ¶
IsReadReplica reports whether the service is a standby read replica (which shares its parent primary's credentials).
func IsValidAddon ¶
IsValidAddon checks if the given add-on is valid (case-sensitive as per API spec)
func ListBranches ¶ added in v0.27.0
func ListBranches(ctx context.Context, client api.ClientWithResponsesInterface, projectID, serviceID string) ([]api.Branch, error)
ListBranches returns serviceID's branches.
func NewAPIClient ¶
func NewAPIClient(ctx context.Context, cfg *config.Config) (*api.ClientWithResponses, string, error)
NewAPIClient initializes a api.ClientWithResponses and returns it along with the current project ID. Credentials are pulled from the environment (if present), or loaded from storage (either the keyring or fallback file). When pulled from the environment, the credentials are first validated by hitting the /auth/info endpoint (which also allows us to fetch the project ID), and the user is identified for the sake of analytics by hitting the /analytics/identify endpoint. When credentials are pulled from storage, those operations should have already been performed via `tiger auth login`.
func ReplicaPoolerWarning ¶
func ReplicaPoolerWarning(target *ConnectionTarget, pooled bool) string
ReplicaPoolerWarning returns the warning to show when pooling was requested for a read replica with no pooler (the connection falls back to direct), or "" otherwise — including for a non-replica target, so callers need no kind check.
func ResolveBranch ¶ added in v0.27.0
func ResolveBranch(ctx context.Context, client api.ClientWithResponsesInterface, projectID, ref string) (*api.Branch, error)
ResolveBranch resolves ref, a branch ID or name, to the branch it names. The branch carries its parent's ID, which every other branch endpoint needs.
func ServiceEnvironmentTag ¶ added in v0.23.0
func ServiceEnvironmentTag(service api.Service) api.EnvironmentTag
ServiceEnvironmentTag returns a service's environment tag. Anything but PROD reads as DEV, since metadata is optional and treating unknowns as protected would have read_only=prod block untagged services.
func ValidAddons ¶
func ValidAddons() []string
ValidAddons returns a slice of all valid add-on values
func ValidPlatforms ¶ added in v0.27.0
func ValidPlatforms() []string
ValidPlatforms returns a slice of all valid platform values
func ValidateAPIKey ¶
func ValidateAPIKey(ctx context.Context, cfg *config.Config, client api.ClientWithResponsesInterface) (*api.AuthInfo, error)
ValidateAPIKey validates the API key by calling the /auth/info endpoint, and returns the caller's identity. It also identifies the user for the sake of analytics. Only PAT credentials reach this path, so the response always carries the apiKey branch.
func ValidateAddons ¶
ValidateAddons validates a slice of add-ons and removes duplicate values
func WaitForBranch ¶ added in v0.27.0
func WaitForBranch(ctx context.Context, args WaitForBranchArgs) error
WaitForBranch polls a branch until it reports TargetStatus, showing its current status next to a spinner in the meantime.
func WaitForService ¶
func WaitForService(ctx context.Context, args WaitForServiceArgs) error
WaitForService polls a service until it reports TargetStatus, showing its current status next to a spinner in the meantime.
Types ¶
type App ¶
type App struct {
// Experimental gates preview-stage commands and MCP tools. Read once from
// TIGER_EXPERIMENTAL at startup; see CLAUDE.md's "Experimental Feature
// Gating".
Experimental bool
// contains filtered or unexported fields
}
App holds shared application state: the config and the API client built from it. For CLI commands it is populated once at the start of the wrapped RunE (see wrapCommands in internal/cmd) and shared by every command handler. For MCP requests, Load is called once per request by the analytics middleware, so config changes and logins/logouts made while the session is open take effect on the next request; handlers then read the loaded state via GetAll and friends.
All state is unexported. Use Load or SetClient to populate it, and GetAll/TryGetAll/GetConfig/GetClient to read it. Concurrency is handled internally via a sync.RWMutex.
func (*App) GetAll ¶
GetAll returns a snapshot of the config, API client, and project ID. Returns an error (and zero values) if the client is unavailable, e.g. because the user isn't logged in. Panics if the App has never been loaded (see getAll).
Callers that only read the config but do reach the API later still use GetAll (discarding the client) so that a missing credential fails fast, before any prompting or other work.
func (*App) GetClient ¶
func (a *App) GetClient() (api.ClientWithResponsesInterface, string, error)
GetClient returns a snapshot of the API client and project ID. Returns an error if the client is unavailable, e.g. because the user isn't logged in. Panics if the App has never been loaded (see getAll).
func (*App) GetConfig ¶
GetConfig returns a snapshot of the config. Panics if the App has never been loaded (see getAll).
func (*App) Load ¶
func (a *App) Load(ctx context.Context) (*config.Config, api.ClientWithResponsesInterface, string, error)
Load loads (or reloads) the config and attempts to create the API client. Returns the config, API client, and project ID. Config errors are returned; API client errors are stored and surfaced by GetClient/GetAll instead (the returned client is simply nil), so commands that don't need the client still run when the user isn't logged in.
func (*App) SetClient ¶
func (a *App) SetClient(client api.ClientWithResponsesInterface, projectID string)
SetClient stores an existing API client and project ID. Use it when a valid client already exists (e.g. after `tiger auth login` builds one to validate credentials) so later readers — analytics in particular — see the new credentials without re-reading them from storage.
func (*App) SetClientFactory ¶
func (a *App) SetClientFactory(f ClientFactory)
SetClientFactory sets a custom factory for API client creation. When set, Load calls this instead of NewAPIClient.
func (*App) SetFlags ¶
SetFlags stores the command's flag set for use by config.Load. Must be called before Load.
func (*App) TryGetAll ¶
TryGetAll returns a snapshot of the config, API client, and project ID like GetAll, but tolerates an unavailable client: the returned client is simply nil. Use it for best-effort work where the API call is optional (e.g. analytics). Panics if the App has never been loaded (see getAll).
type CPUMemoryConfig ¶
CPUMemoryConfig represents an allowed CPU/Memory configuration
func (*CPUMemoryConfig) CPUMillisString ¶
func (c *CPUMemoryConfig) CPUMillisString() *string
func (*CPUMemoryConfig) Matches ¶
func (c *CPUMemoryConfig) Matches(cpuMillis, memoryGBs string) bool
func (*CPUMemoryConfig) MemoryGBsString ¶
func (c *CPUMemoryConfig) MemoryGBsString() *string
func (*CPUMemoryConfig) String ¶
func (c *CPUMemoryConfig) String() string
type CPUMemoryConfigs ¶
type CPUMemoryConfigs []CPUMemoryConfig
func AllowedCPUMemoryConfigs ¶ added in v0.27.0
func AllowedCPUMemoryConfigs(shared, fluid bool) CPUMemoryConfigs
AllowedCPUMemoryConfigs returns the CPU/Memory configurations allowed across platforms: the standard platform's, including shared/shared if shared is set (a service can't be resized onto it), followed by the fluid platform's if fluid is set. Each platform's configurations stay together, in their own order, so the platforms read as separate groups.
func CPUMemoryConfigsFor ¶ added in v0.27.0
func CPUMemoryConfigsFor(platform api.ServicePlatform) CPUMemoryConfigs
CPUMemoryConfigsFor returns the allowed CPU/Memory configurations for a platform. An empty platform is standard, as the API defaults it to.
func FluidCPUMemoryConfigs ¶ added in v0.27.0
func FluidCPUMemoryConfigs() CPUMemoryConfigs
FluidCPUMemoryConfigs returns the allowed CPU/Memory configurations for services on the fluid platform: 8GB of memory per CPU, with no shared option.
func StandardCPUMemoryConfigs ¶ added in v0.27.0
func StandardCPUMemoryConfigs() CPUMemoryConfigs
StandardCPUMemoryConfigs returns the allowed CPU/Memory configurations for services on the standard platform.
func (CPUMemoryConfigs) Parse ¶ added in v0.27.0
func (c CPUMemoryConfigs) Parse(cpuMemoryStr string) (string, string, error)
Parse parses a CPU/memory combination string (e.g., "2 CPU/8 GB") from the configurations and returns millicores and GB. If "shared" is given, returns "shared" for both CPU and memory.
func (CPUMemoryConfigs) String ¶
func (c CPUMemoryConfigs) String() string
String returns a user-friendly string of allowed CPU/Memory combinations
func (CPUMemoryConfigs) Strings ¶
func (c CPUMemoryConfigs) Strings() []string
Strings returns a slice of user-friendly strings of allowed CPU/Memory combinations
func (CPUMemoryConfigs) ValidateAndNormalize ¶ added in v0.27.0
func (c CPUMemoryConfigs) ValidateAndNormalize(cpuMillis, memoryGBs string) (*CPUMemoryConfig, error)
ValidateAndNormalize validates CPU/Memory values against the configurations and fills in whichever one was omitted from the matching configuration.
func (CPUMemoryConfigs) WithoutShared ¶ added in v0.27.0
func (c CPUMemoryConfigs) WithoutShared() CPUMemoryConfigs
WithoutShared returns the configurations other than shared/shared, which a service can't be resized onto.
type CheckConstraint ¶
type CheckConstraint struct {
Name string `json:"name"`
Columns []string `json:"columns,omitempty"` // columns involved in the check (from conkey)
Expression string `json:"expression"` // full constraint def from pg_get_constraintdef, e.g. "CHECK ((age > 0))"
}
CheckConstraint describes a check constraint.
type ClientFactory ¶
type ClientFactory func(ctx context.Context, cfg *config.Config) (api.ClientWithResponsesInterface, string, error)
ClientFactory creates an API client from the loaded config. Tests use it to inject a client while letting Load run normally, so config resolution and flag precedence still go through the real code path.
type ConnectionDetails ¶
type ConnectionDetails struct {
Role string `json:"role,omitempty"`
Password string `json:"password,omitempty"`
Host string `json:"host,omitempty"`
Port int `json:"port,omitempty"`
Database string `json:"database,omitempty"`
IsPooler bool `json:"is_pooler,omitempty"`
// contains filtered or unexported fields
}
func GetConnectionDetails ¶
func GetConnectionDetails(cfg *config.Config, target *ConnectionTarget, opts ConnectionDetailsOptions) (*ConnectionDetails, error)
GetConnectionDetails builds the connection details for a target: it selects the endpoint (the pooler when requested and available, otherwise the direct one) and looks up the password, from the target's credentials, when one is wanted. ConnectionTarget.Details adds the pooler check connecting needs.
func (*ConnectionDetails) String ¶
func (d *ConnectionDetails) String() string
String creates a PostgreSQL connection string from service details
type ConnectionDetailsOptions ¶
type ConnectionDetailsOptions struct {
// Pooled determines whether to use the pooler endpoint (if available)
Pooled bool
// Role is the database role/username to use (e.g., "tsdbadmin")
Role string
// WithPassword determines whether to include the password in the output
WithPassword bool
// InitialPassword is an optional password to use directly (e.g., from service creation response)
// If provided and WithPassword is true, this password will be used
// instead of fetching from password storage. This is useful when password_storage=none.
InitialPassword string
// ReadOnly forces the connection into Tiger Cloud's immutable read-only
// mode by injecting the tsdb_admin.read_only_connection GUC as a startup
// parameter. The GUC cannot be disabled with SET for the duration of the
// session, so this is safe to use even when the LLM controls the SQL.
ReadOnly bool
}
ConnectionDetailsOptions configures how the connection string is built
type ConnectionTarget ¶
type ConnectionTarget struct {
Kind TargetKind
ID string
Name string
// Status decides whether the target accepts connections (see CheckReady).
Status api.DeployStatus
// Environment alone decides a session's read-only verdict, so a replica is
// judged on its own tag rather than its primary's, and a branch, which has
// none, counts as DEV.
Environment api.EnvironmentTag
Endpoint *api.Endpoint
Pooler *api.ConnectionPooler
// Credentials is whose passwords the connection uses: the target itself
// for a service or a branch, the primary for a read replica, which shares
// them.
Credentials CredentialOwner
}
ConnectionTarget is what a database connection goes to: a service, one of its read replica sets, or a branch, reduced to what connecting to it and reporting on it need.
func NewBranchConnectionTarget ¶ added in v0.27.0
func NewBranchConnectionTarget(branch api.Branch) *ConnectionTarget
NewBranchConnectionTarget returns the ConnectionTarget of a branch, which has its own credentials and no pooler.
func NewConnectionTarget ¶ added in v0.26.0
func NewConnectionTarget(ctx context.Context, client api.ClientWithResponsesInterface, projectID string, service api.Service) (*ConnectionTarget, error)
NewConnectionTarget returns the ConnectionTarget of an already-fetched service. A standby read replica connects to its own endpoint but shares the parent primary's credentials, so the parent is fetched here.
func NewReplicaConnectionTarget ¶
func NewReplicaConnectionTarget(replica api.ReadReplicaSet, credentials CredentialOwner) *ConnectionTarget
NewReplicaConnectionTarget returns the ConnectionTarget of a read replica set. The replica supplies the endpoint, and credentials is its primary's (see ServiceCredentials), since a replica shares its primary's passwords.
func NewServiceConnectionTarget ¶ added in v0.27.0
func NewServiceConnectionTarget(service api.Service) *ConnectionTarget
NewServiceConnectionTarget returns the ConnectionTarget of a service, connecting to its own endpoint with its own credentials.
func ResolveConnectionTarget ¶
func ResolveConnectionTarget(ctx context.Context, client api.ClientWithResponsesInterface, projectID, ref string, allowBranches bool) (*ConnectionTarget, error)
ResolveConnectionTarget resolves ref, an ID or a name, to the service, branch, or read replica set it names and works out whose credentials it uses. Branches are a preview, so unless allowBranches is set a ref naming one is reported as not found.
func ResolveConnectionTargetByID ¶
func ResolveConnectionTargetByID(ctx context.Context, client api.ClientWithResponsesInterface, projectID, id string) (*ConnectionTarget, error)
ResolveConnectionTargetByID fetches the service named by id — which may be a primary service ID or a read replica set ID, both of which GetService resolves — and works out whose credentials it uses. Callers that already hold the service use NewConnectionTarget instead.
func (*ConnectionTarget) CheckReady ¶ added in v0.27.0
func (t *ConnectionTarget) CheckReady() error
CheckReady returns nil only when the target accepts connections, and ErrPaused or ErrNotReady otherwise (see the CheckReady function).
func (*ConnectionTarget) Details ¶
func (t *ConnectionTarget) Details(cfg *config.Config, opts ConnectionDetailsOptions) (*ConnectionDetails, error)
Details builds the target's connection details. A requested-but-unavailable pooler is a hard error for a service but silently falls back to direct for a replica (see ReplicaPoolerWarning).
type ConstraintType ¶
type ConstraintType string
ConstraintType represents the type of a table constraint.
const ( ConstraintPrimaryKey ConstraintType = "PRIMARY KEY" ConstraintUnique ConstraintType = "UNIQUE" ConstraintForeignKey ConstraintType = "FOREIGN KEY" )
type ContinuousAggregateInfo ¶
type ContinuousAggregateInfo struct {
CompressionEnabled bool `json:"compression_enabled"`
// MaterializedOnly reports whether queries against the view return only
// already-materialized data (true) or also combine the not-yet-
// materialized recent data in real time (false).
MaterializedOnly bool `json:"materialized_only"`
}
ContinuousAggregateInfo describes TimescaleDB continuous aggregate metadata for a view (see ViewSchema.ContinuousAggregate).
type CredentialOwner ¶ added in v0.27.0
type CredentialOwner struct {
PasswordTarget
// Name names the owner in messages.
Name string
// BranchServiceID is the parent service of an owner that is a branch,
// whose password endpoint is nested under it. It is empty for a service.
BranchServiceID string
// Environment is the owner's own tag, which decides whether read-only mode
// lets its passwords be changed.
Environment api.EnvironmentTag
}
CredentialOwner is the service or branch whose passwords a connection uses.
func BranchCredentials ¶ added in v0.27.0
func BranchCredentials(branch api.Branch) CredentialOwner
BranchCredentials returns a branch as the owner of the credentials its connections use. A branch has its own, separate from its parent's.
func ServiceCredentials ¶ added in v0.27.0
func ServiceCredentials(service api.Service) CredentialOwner
ServiceCredentials returns a service as the owner of the credentials its connections use, which its read replica sets share.
type DatabaseSchema ¶
type DatabaseSchema struct {
ID string `json:"id"`
Name string `json:"name"`
Schemas []NamespacedSchema `json:"schemas"`
}
DatabaseSchema holds complete schema information for a database, grouped by namespace (Postgres schema).
type EnumSchema ¶
type EnumSchema struct {
Name string `json:"name"`
// Comment is the type's COMMENT ON TYPE text. Only populated when
// comments are requested.
Comment string `json:"comment,omitempty"`
Values []string `json:"values,omitempty"`
}
EnumSchema describes an enum type.
type ExclusionConstraint ¶
type ExclusionConstraint struct {
Name string `json:"name"`
Definition string `json:"definition"` // full constraint def from pg_get_constraintdef, e.g. "EXCLUDE USING gist (circle WITH &&)"
}
ExclusionConstraint describes an exclusion constraint.
type ExecuteQueryArgs ¶ added in v0.24.0
type ExecuteQueryArgs struct {
Query string
Parameters []string
Role string
Pooled bool
// ReadOnly opens the session in Tiger Cloud's immutable read-only mode.
ReadOnly bool
// MaxRows caps the rows returned per result set and MaxBytes caps the
// approximate serialized size of all rows returned. Zero means no cap.
// Only the MCP tool sets them, to bound how much data reaches an agent's
// context; the CLI returns everything the query produced.
MaxRows int
MaxBytes int
}
ExecuteQueryArgs configures a call to ExecuteQuery.
type ExitCodeError ¶
type ExitCodeError struct {
// contains filtered or unexported fields
}
ExitCodeError creates an error that will cause the program to exit with the specified code
func (ExitCodeError) Error ¶
func (e ExitCodeError) Error() string
func (ExitCodeError) ExitCode ¶
func (e ExitCodeError) ExitCode() int
func (ExitCodeError) Unwrap ¶
func (e ExitCodeError) Unwrap() error
type Extension ¶ added in v0.27.0
type Extension struct {
Name string `json:"name"`
Version string `json:"version"`
Schema string `json:"schema"`
Description string `json:"description,omitempty"`
}
Extension is an extension installed in a database.
type FetchServiceLogsArgs ¶
type FetchServiceLogsArgs struct {
Client api.ClientWithResponsesInterface
ProjectID string
ServiceID string
Tail int
Since *time.Time
Until *time.Time
// Node selects a specific service node to fetch logs from, for services
// with HA replicas. If nil, the backend returns logs for the primary.
Node *int
}
type FetchServiceSchemaArgs ¶ added in v0.26.0
type FetchServiceSchemaArgs struct {
Role string
Pooled bool
// Schema, if non-empty, limits the fetch to a single namespace.
Schema string
// IncludeInternal disables the exclusion filters, adding catalog (pg_*)
// and extension-owned objects.
IncludeInternal bool
// IncludeDefinitions fetches full object definitions (view SELECTs and
// routine bodies), omitted by default since they can be large and may
// embed secrets.
IncludeDefinitions bool
// IncludeComments fetches object comments (COMMENT ON text), omitted by
// default to keep the output concise.
IncludeComments bool
}
FetchServiceSchemaArgs configures a call to FetchServiceSchema.
type ForeignTableInfo ¶
type ForeignTableInfo struct {
Server string `json:"server"` // pg_foreign_server.srvname
Wrapper string `json:"wrapper"` // pg_foreign_data_wrapper.fdwname
Options []string `json:"options,omitempty"` // ftoptions as "key=value" strings
}
ForeignTableInfo describes the FDW binding of a foreign table. Only table-level options (pg_foreign_table.ftoptions, e.g. schema_name / table_name for postgres_fdw) are exposed; server-level options and user mappings, which can carry credentials, are never fetched.
type HypertableInfo ¶
type HypertableInfo struct {
CompressionEnabled bool `json:"compression_enabled"`
NumChunks int `json:"num_chunks"`
}
HypertableInfo describes TimescaleDB hypertable metadata for a table.
type IndexSchema ¶
type IndexSchema struct {
Name string `json:"name"`
Columns string `json:"columns"` // column expressions, e.g. "status" or "created_at DESC"
Definition string `json:"definition,omitempty"`
IsUnique bool `json:"is_unique,omitempty"`
WhereClause string `json:"where_clause,omitempty"` // for partial indexes, empty if not partial
}
IndexSchema describes an index.
type KeyringStorage ¶
type KeyringStorage struct{}
KeyringStorage implements password storage using system keyring
func (*KeyringStorage) Get ¶
func (k *KeyringStorage) Get(target PasswordTarget, role string) (string, error)
func (*KeyringStorage) GetStorageResult ¶
func (k *KeyringStorage) GetStorageResult(err error, password string) PasswordStorageResult
func (*KeyringStorage) Remove ¶
func (k *KeyringStorage) Remove(target PasswordTarget, role string) error
func (*KeyringStorage) Save ¶
func (k *KeyringStorage) Save(target PasswordTarget, password string, role string) error
type NamespacedSchema ¶
type NamespacedSchema struct {
Name string `json:"name"`
// Comment is the schema's COMMENT ON SCHEMA text. Only populated when
// comments are requested. A schema with a comment but no visible objects
// is not surfaced just for its comment.
Comment string `json:"comment,omitempty"`
Tables []TableSchema `json:"tables,omitempty"`
Views []ViewSchema `json:"views,omitempty"`
MaterializedViews []ViewSchema `json:"materialized_views,omitempty"`
Enums []EnumSchema `json:"enums,omitempty"`
Functions []Routine `json:"functions,omitempty"`
Procedures []Routine `json:"procedures,omitempty"`
}
NamespacedSchema groups the objects belonging to a single Postgres schema.
type NoStorage ¶
type NoStorage struct{}
NoStorage implements no password storage (passwords are not saved)
func (*NoStorage) GetStorageResult ¶
func (n *NoStorage) GetStorageResult(err error, password string) PasswordStorageResult
type PartitionInfo ¶
type PartitionInfo struct {
Name string `json:"name"`
// Schema is the partition child's schema. It is only populated when the
// partition lives in a different schema than its parent table (PostgreSQL
// allows this), so that callers can schema-qualify the partition
// correctly. When empty, the partition shares its parent's schema.
Schema string `json:"schema,omitempty"`
// Bound is the partition's bound expression (from pg_get_expr on
// relpartbound), e.g. "FOR VALUES FROM ('2024-01-01') TO ('2025-01-01')".
Bound string `json:"bound,omitempty"`
}
PartitionInfo describes a single child partition of a partitioned table.
type PasswordStorage ¶
type PasswordStorage interface {
Save(target PasswordTarget, password string, role string) error
Get(target PasswordTarget, role string) (string, error)
Remove(target PasswordTarget, role string) error
GetStorageResult(err error, password string) PasswordStorageResult
}
PasswordStorage defines the interface for password storage implementations
func GetPasswordStorage ¶
func GetPasswordStorage(cfg *config.Config) PasswordStorage
GetPasswordStorage returns the appropriate PasswordStorage implementation based on configuration
type PasswordStorageResult ¶
type PasswordStorageResult struct {
Success bool `json:"success"`
Method string `json:"method"` // "keyring", "pgpass", or "none"
Message string `json:"message"` // Human-readable message
}
PasswordStorageResult contains the result of password storage operations
func SavePasswordWithResult ¶
func SavePasswordWithResult(cfg *config.Config, target PasswordTarget, password string, role string) (PasswordStorageResult, error)
SavePasswordWithResult handles saving a password and returns both error and result info
type PasswordTarget ¶ added in v0.27.0
PasswordTarget is what a stored password belongs to: a service or a branch. The keyring keys a password by project and ID, and ~/.pgpass by the endpoint's host and port.
func BranchPasswordTarget ¶ added in v0.27.0
func BranchPasswordTarget(branch api.Branch) PasswordTarget
BranchPasswordTarget returns the PasswordTarget of a branch's own passwords.
func ServicePasswordTarget ¶ added in v0.27.0
func ServicePasswordTarget(service api.Service) PasswordTarget
ServicePasswordTarget returns the PasswordTarget of a service's own passwords.
type PgpassStorage ¶
type PgpassStorage struct{}
PgpassStorage implements password storage using ~/.pgpass file
func (*PgpassStorage) Get ¶
func (p *PgpassStorage) Get(target PasswordTarget, role string) (string, error)
func (*PgpassStorage) GetStorageResult ¶
func (p *PgpassStorage) GetStorageResult(err error, password string) PasswordStorageResult
func (*PgpassStorage) Remove ¶
func (p *PgpassStorage) Remove(target PasswordTarget, role string) error
func (*PgpassStorage) Save ¶
func (p *PgpassStorage) Save(target PasswordTarget, password string, role string) error
type QueryResult ¶ added in v0.24.0
QueryResult is the complete result of a query execution. Callers render it themselves (a table for the CLI, structured output for MCP), so it carries no JSON tags.
type Resolved ¶ added in v0.27.0
Resolved is what a ref resolved to. Exactly one of its fields is set.
type ResultSet ¶ added in v0.24.0
type ResultSet struct {
CommandTag string `json:"command_tag"`
Columns []Column `json:"columns,omitempty"`
Rows [][]*string `json:"rows,omitzero"`
RowsAffected int64 `json:"rows_affected"`
Truncated bool `json:"truncated,omitempty"`
}
ResultSet is the result of a single statement. Rows uses omitzero rather than omitempty so the two empty cases stay distinct: a statement that returns no rows at all (DDL, INSERT/UPDATE/DELETE) leaves it nil and omits the field, while a SELECT that matched nothing reports an empty list.
type Routine ¶
type Routine struct {
Name string `json:"name"`
// Arguments is the identity argument list (e.g. "integer, text"),
// which distinguishes overloaded routines that share a name. Empty for
// a routine that takes no arguments.
Arguments string `json:"arguments,omitempty"`
Type RoutineType `json:"type"`
// Comment is the routine's COMMENT ON FUNCTION/PROCEDURE text. Only
// populated when comments are requested.
Comment string `json:"comment,omitempty"`
Definition string `json:"definition,omitempty"`
}
Routine describes a function or procedure.
type RoutineType ¶
type RoutineType string
RoutineType is the type of a routine.
const ( RoutineFunction RoutineType = "FUNCTION" RoutineProcedure RoutineType = "PROCEDURE" )
type SchemaIdent ¶
SchemaIdent identifies the service whose schema was fetched. Its values populate DatabaseSchema.ID and DatabaseSchema.Name for display.
type SchemaNotFoundError ¶
type SchemaNotFoundError struct {
// Schema is the requested namespace that was not found.
Schema string
// Available lists the schemas the connecting user can access (i.e. holds
// USAGE on), minus the internal namespaces a default browse hides unless
// --internal is set. It is a best-effort suggestion list, not a guarantee
// that each schema would produce non-empty results (a schema whose
// contents are entirely extension-owned still renders empty on a default
// browse). It is nil when enumeration failed (in which case ListErr is
// set).
Available []string
// ListErr is non-nil when listing the available schemas failed.
ListErr error
}
SchemaNotFoundError indicates the requested namespace does not exist. It carries a friendly message listing the available schemas when they could be enumerated. Callers can detect it with errors.As to distinguish a mistyped schema (a client input error) from an upstream/connection failure.
func (*SchemaNotFoundError) Error ¶
func (e *SchemaNotFoundError) Error() string
Error implements the error interface.
func (*SchemaNotFoundError) Unwrap ¶
func (e *SchemaNotFoundError) Unwrap() error
Unwrap exposes the underlying listing error (if any) for errors.Is/As.
type Spinner ¶
type Spinner interface {
// Update changes the spinner's displayed message.
Update(message string)
// Stop terminates the spinner program and waits for it to finish.
Stop()
}
func NewSpinner ¶
func NewSpinner(args SpinnerArgs) Spinner
NewSpinner creates and returns a new Spinner for displaying animated status messages. If the output is nil or io.Discard, it returns a no-op spinner. If both streams are terminals, it uses bubbletea to dynamically update the spinner and message in place. Otherwise it prints each message on a new line without animation.
type SpinnerArgs ¶
type SpinnerArgs struct {
// Input is read so the animated spinner can see Ctrl+C. BubbleTea asks the
// terminal for keyboard disambiguation, and terminals that honor it deliver
// Ctrl+C as an escape sequence on stdin instead of as a SIGINT — so without
// stdin attached the keypress has nowhere to go and Ctrl+C does nothing.
Input io.Reader
Output io.Writer
Message string
// Cancel is called when the user presses Ctrl+C. It lets the caller's
// polling loop unwind through its own context rather than being torn down
// from underneath.
//
// Set it whenever the animated spinner might be chosen: BubbleTea leaves
// Ctrl+C as a key press rather than a SIGINT, so a spinner without a Cancel
// gives the user no way at all to interrupt the wait.
Cancel context.CancelFunc
}
type TableColumnSchema ¶
type TableColumnSchema struct {
Name string `json:"name"`
Type string `json:"type"`
// Comment is the column's COMMENT ON COLUMN text. Only populated when
// comments are requested.
Comment string `json:"comment,omitempty"`
NotNull bool `json:"not_null,omitempty"`
Default string `json:"default,omitempty"` // empty if no default
IsSerial bool `json:"is_serial,omitempty"` // true if SERIAL/BIGSERIAL/SMALLSERIAL (has sequence, not identity)
IdentityType string `json:"identity_type,omitempty"` // 'a' = ALWAYS, 'd' = BY DEFAULT, ” = not identity
}
TableColumnSchema holds schema information for a table column.
type TableConstraint ¶
type TableConstraint struct {
Type ConstraintType `json:"type"`
Name string `json:"name"`
Columns []string `json:"columns,omitempty"`
RefTable string `json:"ref_table,omitempty"` // for FK
RefColumns []string `json:"ref_columns,omitempty"` // for FK
}
TableConstraint describes a constraint (single or multi-column).
type TableSchema ¶
type TableSchema struct {
Name string `json:"name"`
// Comment is the table's COMMENT ON TABLE text. Only populated when
// comments are requested.
Comment string `json:"comment,omitempty"`
Columns []TableColumnSchema `json:"columns,omitempty"`
Constraints []TableConstraint `json:"constraints,omitempty"` // PK, UK, FK constraints (single and multi-column)
Indexes []IndexSchema `json:"indexes,omitempty"`
Checks []CheckConstraint `json:"checks,omitempty"`
Exclusions []ExclusionConstraint `json:"exclusions,omitempty"`
Triggers []TriggerSchema `json:"triggers,omitempty"`
// Partitions lists the direct child partitions of a partitioned table.
// Only populated for partitioned tables (relkind 'p'). Leaf partitions
// are normally hidden as standalone tables, but in a multi-level hierarchy
// an intermediate partitioned table is shown both as an entry here (under
// its parent) and as its own table carrying its sub-partitions. When a
// single schema is requested, a leaf whose parent lives in a different
// schema is shown as a standalone table instead (see leafPartitionExclusion).
Partitions []PartitionInfo `json:"partitions,omitempty"`
Hypertable *HypertableInfo `json:"hypertable,omitempty"`
// Foreign is the FDW binding of a foreign table (relkind 'f'). Nil for
// regular tables. Foreign tables are modeled as tables because they
// behave like them (columns, CHECK constraints, triggers, partition
// membership); this field is what distinguishes them.
Foreign *ForeignTableInfo `json:"foreign,omitempty"`
}
TableSchema holds schema information for a table.
type TargetKind ¶ added in v0.27.0
type TargetKind int
TargetKind is the kind of resource a ConnectionTarget is.
const ( TargetService TargetKind = iota TargetReadReplica TargetBranch )
type TriggerSchema ¶
type TriggerSchema struct {
Name string `json:"name"`
Timing string `json:"timing"`
Manipulation string `json:"manipulation"`
Statement string `json:"statement"`
}
TriggerSchema describes a single trigger on a table.
type ViewColumnSchema ¶
type ViewColumnSchema struct {
Name string `json:"name"`
Type string `json:"type"`
// Comment is the column's COMMENT ON COLUMN text. Only populated when
// comments are requested.
Comment string `json:"comment,omitempty"`
}
ViewColumnSchema holds column info for views (simpler than table columns).
type ViewSchema ¶
type ViewSchema struct {
Name string `json:"name"`
// Comment is the view's COMMENT ON (MATERIALIZED) VIEW text. Only
// populated when comments are requested.
Comment string `json:"comment,omitempty"`
Columns []ViewColumnSchema `json:"columns,omitempty"`
// Definition is the view's defining SELECT (from pg_get_viewdef).
Definition string `json:"definition,omitempty"`
// Indexes are only populated for materialized views.
Indexes []IndexSchema `json:"indexes,omitempty"`
// Triggers lists triggers defined on the view (e.g. INSTEAD OF
// triggers on a regular view). Not applicable to materialized views.
Triggers []TriggerSchema `json:"triggers,omitempty"`
// ContinuousAggregate is TimescaleDB continuous aggregate metadata. Nil
// for ordinary views. A continuous aggregate is a regular view (relkind
// 'v') over an internal materialization hypertable, so it appears under
// Views; this field is what distinguishes it. When set and definitions
// were requested, Definition holds the user's original defining query
// rather than the rewritten SELECT over the internal materialization
// hypertable that pg_get_viewdef returns.
ContinuousAggregate *ContinuousAggregateInfo `json:"continuous_aggregate,omitempty"`
}
ViewSchema holds schema information for a view or materialized view.
type WaitForBranchArgs ¶ added in v0.27.0
type WaitForBranchArgs struct {
Client api.ClientWithResponsesInterface
ProjectID string
ServiceID string // the branch's parent
BranchID string
// Branch is the branch as last returned by the API. Unlike
// WaitForServiceArgs.Service, the whole branch is replaced on every poll,
// so fields that only appear once the branch is provisioned (its endpoint)
// are there for the caller afterwards.
Branch *api.Branch
// TargetStatus, Input, Output, Timeout, and TimeoutMsg work as in
// WaitForServiceArgs.
TargetStatus api.DeployStatus
Input io.Reader
Output io.Writer
Timeout time.Duration
TimeoutMsg string
}
type WaitForServiceArgs ¶
type WaitForServiceArgs struct {
Client api.ClientWithResponsesInterface
ProjectID string
ServiceID string
// Service is the service as last returned by the API. Its status decides
// whether polling is needed at all, and it is updated in place as polling
// proceeds so the caller can output the final state afterwards.
Service *api.Service
// TargetStatus ends the wait once the service reports it. Every other
// status, including UNSTABLE, keeps polling: transitional states pass and
// unstable services often recover on their own.
TargetStatus api.DeployStatus
// Input lets the spinner pick up a Ctrl+C and cancel the wait. See
// [SpinnerArgs.Input] for why the spinner needs stdin at all.
Input io.Reader
Output io.Writer
Timeout time.Duration
TimeoutMsg string
}