alloydb

package
v1.18.5 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PublicIP is the value for public IP connections.
	PublicIP = "PUBLIC"
	// PrivateIP is the value for private IP connections.
	PrivateIP = "PRIVATE"
	// PSC designates PSC-based connections.
	PSC = "PSC"
)
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 {
	Instance   InstanceURI
	IPAddrs    map[string]string
	ClientCert tls.Certificate
	RootCAs    *x509.CertPool
	Expiration time.Time
}

ConnectionInfo holds all the data necessary to connect to an instance.

type InstanceURI added in v1.2.2

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

InstanceURI represents an AlloyDB instance.

func ParseInstURI added in v1.2.2

func ParseInstURI(cn string) (InstanceURI, error)

ParseInstURI initializes a new InstanceURI struct.

func (InstanceURI) Cluster added in v1.15.0

func (i InstanceURI) Cluster() string

Cluster returns the name of the cluster.

func (InstanceURI) Name added in v1.15.0

func (i InstanceURI) Name() string

Name returns the name of the instance.

func (InstanceURI) Project added in v1.15.0

func (i InstanceURI) Project() string

Project returns the project ID of the cluster.

func (InstanceURI) Region added in v1.15.0

func (i InstanceURI) Region() string

Region returns the region (aka location) of the cluster.

func (*InstanceURI) String added in v1.2.2

func (i *InstanceURI) String() string

String returns a short-hand representation of an instance URI.

func (*InstanceURI) URI added in v1.10.0

func (i *InstanceURI) URI() string

URI returns the full URI specifying an instance.

type LazyRefreshCache added in v1.10.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.10.0

func NewLazyRefreshCache(
	uri InstanceURI,
	l debug.ContextLogger,
	client *alloydbadmin.AlloyDBAdminClient,
	key *rsa.PrivateKey,
	_ time.Duration,
	dialerID string,
	userAgent string,
	mr telv2.MetricRecorder,
) *LazyRefreshCache

NewLazyRefreshCache initializes a new LazyRefreshCache.

func (*LazyRefreshCache) Close added in v1.10.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.10.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.10.0

func (c *LazyRefreshCache) ForceRefresh()

ForceRefresh invalidates the caches and configures the next call to ConnectionInfo to retrieve a fresh 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 AlloyDB instance by periodically calling the AlloyDB 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(
	instance InstanceURI,
	l debug.ContextLogger,
	client *alloydbadmin.AlloyDBAdminClient,
	key *rsa.PrivateKey,
	refreshTimeout time.Duration,
	dialerID string,
	userAgent string,
	mr telv2.MetricRecorder,
) *RefreshAheadCache

NewRefreshAheadCache initializes a new cache that proactively refreshes the caches connection info.

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 AlloyDB 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) of the AlloyDB 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 if valid.

type StaticConnectionInfoCache added in v1.10.0

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

StaticConnectionInfoCache provides connection info that is never refreshed.

func NewStaticConnectionInfoCache added in v1.10.0

func NewStaticConnectionInfoCache(
	inst InstanceURI,
	l debug.ContextLogger,
	r io.Reader,
) (*StaticConnectionInfoCache, error)

NewStaticConnectionInfoCache creates a connection info cache that will always return the predefined connection info within the provided io.Reader

func (*StaticConnectionInfoCache) Close added in v1.10.0

Close is a no-op.

func (*StaticConnectionInfoCache) ConnectionInfo added in v1.10.0

func (c *StaticConnectionInfoCache) ConnectionInfo(
	_ context.Context,
) (ConnectionInfo, error)

ConnectionInfo returns the connection info for the specified instance URI as loaded from the provided io.Reader.

func (*StaticConnectionInfoCache) ForceRefresh added in v1.10.0

func (*StaticConnectionInfoCache) ForceRefresh()

ForceRefresh is a no-op as the cache holds only static connection information and does no refresh.

Jump to

Keyboard shortcuts

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