cloudsql

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 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 ConnectionInfo added in v1.9.0

type ConnectionInfo struct {
	ConnectionName    instance.ConnName
	ClientCertificate tls.Certificate
	ServerCaCert      *x509.Certificate
	DBVersion         string
	Expiration        time.Time
	// contains filtered or unexported fields
}

ConnectionInfo contains all necessary information to connect securely to the server-side Proxy running on a Cloud SQL instance.

func (ConnectionInfo) Addr added in v1.9.0

func (c ConnectionInfo) Addr(ipType string) (string, error)

Addr returns the IP address or DNS name for the given IP type.

func (ConnectionInfo) TLSConfig added in v1.9.0

func (c ConnectionInfo) TLSConfig() *tls.Config

TLSConfig constructs a TLS configuration for the given connection info.

type LazyRefreshCache added in v1.9.0

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

LazyRefreshCache is caches connection info and refreshes the cache only when a caller requests connection info and the current certificate is expired.

func NewLazyRefreshCache added in v1.9.0

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

NewLazyRefreshCache initializes a new LazyRefreshCache.

func (*LazyRefreshCache) Close added in v1.9.0

func (c *LazyRefreshCache) Close() error

Close is a no-op and provided purely for a consistent interface with other caching types.

func (*LazyRefreshCache) ConnectionInfo added in v1.9.0

func (c *LazyRefreshCache) ConnectionInfo(
	ctx context.Context,
) (ConnectionInfo, error)

ConnectionInfo returns connection info for the associated instance. New connection info is retrieved under two conditions: - the current connection info's certificate has expired, or - a caller has separately called ForceRefresh

func (*LazyRefreshCache) ForceRefresh added in v1.9.0

func (c *LazyRefreshCache) ForceRefresh()

ForceRefresh invalidates the caches and configures the next call to ConnectionInfo to retrieve a fresh connection info.

func (*LazyRefreshCache) UpdateRefresh added in v1.9.0

func (c *LazyRefreshCache) UpdateRefresh(useIAMAuthNDial *bool)

UpdateRefresh updates the refresh operation to either enable or disable IAM authentication for the cached connection info.

type RefreshAheadCache added in v1.9.0

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

RefreshAheadCache 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 NewRefreshAheadCache added in v1.9.0

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

NewRefreshAheadCache initializes a new Instance given an instance connection name

func (*RefreshAheadCache) Close added in v1.9.0

func (i *RefreshAheadCache) 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 (*RefreshAheadCache) ConnectionInfo added in v1.9.0

func (i *RefreshAheadCache) ConnectionInfo(ctx context.Context) (ConnectionInfo, error)

ConnectionInfo 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 (*RefreshAheadCache) ForceRefresh added in v1.9.0

func (i *RefreshAheadCache) 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 (*RefreshAheadCache) UpdateRefresh added in v1.9.0

func (i *RefreshAheadCache) 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