config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config loads server configuration from environment variables.

Index

Constants

View Source
const (

	// TransportStdio runs the server over stdin/stdout (default).
	TransportStdio = "stdio"
	// TransportHTTP runs the server as an HTTP service with bearer-token auth.
	TransportHTTP = "http"
)

Variables

This section is empty.

Functions

func ParseLogLevel

func ParseLogLevel(s string) (zapcore.Level, error)

ParseLogLevel converts a textual log level to zapcore.Level. Accepts debug, info, warn, error (case-insensitive).

Types

type Config

type Config struct {
	DatabaseURL        string
	Host               string
	Port               int
	User               string
	Password           string
	SSLMode            string
	CAPath             string
	CertFile           string
	KeyFile            string
	EnableWriteQueries bool
	QueryTimeout       time.Duration
	MaxRowsCount       int64
	LogLevel           zapcore.Level
	LogPath            string
	MaxConns           int32
	// TxnQoS is set only when CRDB_MCP_TXN_QOS is explicit. Empty means
	// "let the adapter decide" - the adapter respects a DSN-supplied value
	// if present, otherwise falls back to its background default.
	TxnQoS            string
	AllowPasswordAuth bool
	Transport         string
	HTTPListenAddr    string
	BearerToken       string
	TLSCert           string
	TLSKey            string
	AllowInsecureHTTP bool
	// AllowNoBearer lets HTTP mode start without a bearer token. Auth must
	// then be provided upstream (reverse proxy, gateway, mTLS).
	AllowNoBearer bool
	// AllowInsecureDB permits the sslmode values that can run without
	// TLS (disable, allow, prefer). Local development only.
	AllowInsecureDB bool
	OTelFile        string
	OTLPEndpoint    string
}

Config holds the server configuration.

func Load

func Load() (*Config, error)

Load reads configuration from environment variables. Two auth modes are supported, in priority order:

  1. CRDB_DATABASE_URL - a full libpq connection string (preferred when set).
  2. Cert-based env vars - CRDB_HOST, CRDB_USERNAME, CRDB_SSL_CERTFILE, CRDB_SSL_KEYFILE, and CRDB_SSL_CA_PATH for verify-ca/verify-full.

func (*Config) DSN

func (c *Config) DSN() string

DSN returns the libpq connection string for the configured auth mode.

func (*Config) InsecureDB

func (c *Config) InsecureDB() bool

InsecureDB reports whether the database connection can run without TLS.

func (*Config) OTelEnabled

func (c *Config) OTelEnabled() bool

OTelEnabled reports whether an OpenTelemetry exporter is configured.

func (*Config) TLSEnabled

func (c *Config) TLSEnabled() bool

TLSEnabled reports whether the HTTP transport should be served over TLS.

Jump to

Keyboard shortcuts

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