cloudsql

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PublicIP is the value for public IP Cloud SQL instances.
	PublicIP = "PUBLIC"
	// PrivateIP is the value for private IP Cloud SQL instances.
	PrivateIP = "PRIVATE"
	// PSC is the value for private service connect Cloud SQL instances.
	PSC = "PSC"
	// AutoIP selects public IP if available and otherwise selects private
	// IP.
	AutoIP = "AutoIP"
)
View Source
const (

	// RefreshTimeout is the maximum amount of time to wait for a refresh
	// cycle to complete. This value should be greater than the
	// refreshInterval.
	RefreshTimeout = 60 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Instance

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

Instance manages the information used to connect to the Cloud SQL instance by periodically calling the Cloud SQL Admin API. It automatically refreshes the required information approximately 4 minutes before the previous certificate expires (every ~56 minutes).

func NewInstance

func NewInstance(
	cn instance.ConnName,
	l debug.Logger,
	client *sqladmin.Service,
	key *rsa.PrivateKey,
	refreshTimeout time.Duration,
	ts oauth2.TokenSource,
	dialerID string,
	useIAMAuthNDial bool,
) *Instance

NewInstance initializes a new Instance given an instance connection name

func (*Instance) Close

func (i *Instance) Close() error

Close closes the instance; it stops the refresh cycle and prevents it from making additional calls to the Cloud SQL Admin API.

func (*Instance) ConnectInfo

func (i *Instance) ConnectInfo(ctx context.Context, ipType string) (string, *tls.Config, error)

ConnectInfo returns an IP address specified by ipType (i.e., public or private) and a TLS config that can be used to connect to a Cloud SQL instance.

func (*Instance) ForceRefresh

func (i *Instance) ForceRefresh()

ForceRefresh triggers an immediate refresh operation to be scheduled and used for future connection attempts. Until the refresh completes, the existing connection info will be available for use if valid.

func (*Instance) InstanceEngineVersion

func (i *Instance) InstanceEngineVersion(ctx context.Context) (string, error)

InstanceEngineVersion returns the engine type and version for the instance. The value corresponds to one of the following types for the instance: https://cloud.google.com/sql/docs/mysql/admin-api/rest/v1beta4/SqlDatabaseVersion

func (*Instance) OpenConns

func (i *Instance) OpenConns() *uint64

OpenConns returns a pointer to the number of open connections to faciliate changing the value using atomics.

func (*Instance) UpdateRefresh added in v0.4.0

func (i *Instance) UpdateRefresh(useIAMAuthNDial *bool)

UpdateRefresh cancels all existing refresh attempts and schedules new attempts with the provided config only if it differs from the current configuration.

Jump to

Keyboard shortcuts

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