Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UnixAddress ¶
UnixAddress is defined as a function to distinguish between Linux-based implementations where the dir and inst and simply joins, and Windows-based implementations where the inst must be further altered.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client proxies connections from a local client to the remote server side proxy for multiple Cloud SQL instances.
func NewClient ¶
func NewClient(ctx context.Context, d cloudsql.Dialer, l cloudsql.Logger, conf *Config) (*Client, error)
NewClient completes the initial setup required to get the proxy to a "steady" state.
func (*Client) CheckConnections ¶
CheckConnections dials each registered instance and reports any errors that may have occurred.
type Config ¶
type Config struct {
// UserAgent is the user agent to use when connecting to the cloudsql instance
UserAgent string
// Token is the Bearer token used for authorization.
Token string
// CredentialsFile is the path to a service account key.
CredentialsFile string
// GcloudAuth set whether to use Gcloud's config helper to retrieve a
// token for authentication.
GcloudAuth bool
// Addr is the address on which to bind all instances.
Addr string
// Port is the initial port to bind to. Subsequent instances bind to
// increments from this value.
Port int
// APIEndpointURL is the URL of the google cloud sql api. When left blank,
// the proxy will use the main public api: https://sqladmin.googleapis.com/
APIEndpointURL string
// UnixSocket is the directory where Unix sockets will be created,
// connected to any Instances. If set, takes precedence over Addr and Port.
UnixSocket string
// IAMAuthN enables automatic IAM DB Authentication for all instances.
// Postgres-only.
IAMAuthN bool
// MaxConnections are the maximum number of connections the Client may
// establish to the Cloud SQL server side proxy before refusing additional
// connections. A zero-value indicates no limit.
MaxConnections uint64
// WaitOnClose sets the duration to wait for connections to close before
// shutting down. Not setting this field means to close immediately
// regardless of any open connections.
WaitOnClose time.Duration
// PrivateIP enables connections via the database server's private IP address
// for all instances.
PrivateIP bool
// Instances are configuration for individual instances. Instance
// configuration takes precedence over global configuration.
Instances []InstanceConnConfig
// QuotaProject is the ID of the Google Cloud project to use to track
// API request quotas.
QuotaProject string
// StructuredLogs sets all output to use JSON in the LogEntry format.
// See https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry
StructuredLogs bool
// Dialer specifies the dialer to use when connecting to Cloud SQL
// instances.
Dialer cloudsql.Dialer
}
Config contains all the configuration provided by the caller.
func (*Config) DialOptions ¶
func (c *Config) DialOptions(i InstanceConnConfig) []cloudsqlconn.DialOption
DialOptions interprets appropriate dial options for a particular instance configuration
func (*Config) DialerOptions ¶
DialerOptions builds appropriate list of options from the Config values for use by cloudsqlconn.NewClient()
type InstanceConnConfig ¶
type InstanceConnConfig struct {
// Name is the instance connection name.
Name string
// Addr is the address on which to bind a listener for the instance.
Addr string
// Port is the port on which to bind a listener for the instance.
Port int
// UnixSocket is the directory where a Unix socket will be created,
// connected to the Cloud SQL instance. If set, takes precedence over Addr
// and Port.
UnixSocket string
// IAMAuthN enables automatic IAM DB Authentication for the instance.
// Postgres-only. If it is nil, the value was not specified.
IAMAuthN *bool
// PrivateIP tells the proxy to attempt to connect to the db instance's
// private IP address instead of the public IP address
PrivateIP *bool
}
InstanceConnConfig holds the configuration for an individual instance connection.