config

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2022 License: Apache-2.0, MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoPrimaryAddress = errors.New("no primary address found for database")

ErrNoPrimaryAddress is returned when a database does not have a valid primary address.

Functions

This section is empty.

Types

type GCloudProvider

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

GCloudProvider is a configuration provider for Google Cloud managed databases.

func (*GCloudProvider) GetAuthorityCertificate

func (p *GCloudProvider) GetAuthorityCertificate() (*x509.Certificate, error)

GetAuthorityCertificate returns the latest root certificate authority.

func (*GCloudProvider) GetClientCertificate

func (p *GCloudProvider) GetClientCertificate() (*tls.Certificate, error)

GetClientCertificate returns the latest ephemeral client certificate.

func (*GCloudProvider) GetPrimaryAddress

func (p *GCloudProvider) GetPrimaryAddress() (string, error)

GetPrimaryAddress returns the active primary ip address of the database (eg. its public load balancer).

func (*GCloudProvider) RefreshConfig

func (p *GCloudProvider) RefreshConfig() error

RefreshConfig downloads the latest database configuration and issues an updated client certificate.

type Provider

type Provider interface {
	GetPrimaryAddress() (string, error)
	GetClientCertificate() (*tls.Certificate, error)
	GetAuthorityCertificate() (*x509.Certificate, error)
	RefreshConfig() error
}

Provider is a cached configuration provider. We cache the database configuration so that we don't spam the Google Cloud API and use excess API quota.

func NewConfigProvider

func NewConfigProvider(ctx context.Context,
	apiClient *api.Client, instance string,
	minRefreshInterval, periodicRefreshInterval time.Duration) (Provider, error)

NewConfigProvider constructs a new configuration provider from an API client and instance.

Jump to

Keyboard shortcuts

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