interfaces

package
v2.2.0-dev.21 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: Apache-2.0 Imports: 7 Imported by: 29

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BootstrapHandler

type BootstrapHandler func(
	ctx context.Context,
	wg *sync.WaitGroup,
	startupTimer startup.Timer,
	dic *di.Container) (success bool)

BootstrapHandler defines the contract each bootstrap handler must fulfill. Implementation returns true if the handler completed successfully, false if it did not.

type CertificateProvider

type CertificateProvider interface {
	// GetCertificateKeyPair retrieves certificate pair.
	GetCertificateKeyPair(path string) (config.CertKeyPair, error)
}

CertificateProvider interface provides an abstraction for obtaining certificate pair.

type Configuration

type Configuration interface {
	// These two interfaces have been separated out for use in the custom configuration capability for
	// App and Device services
	UpdatableConfig
	WritableConfig

	// EmptyWritablePtr returns a pointer to a service-specific empty WritableInfo struct.  It is used by the bootstrap to
	// provide the appropriate structure to registry.Client's WatchForChanges().
	EmptyWritablePtr() interface{}

	// GetBootstrap returns the configuration elements required by the bootstrap.
	GetBootstrap() config.BootstrapConfiguration

	// GetLogLevel returns the current ConfigurationStruct's log level.
	GetLogLevel() string

	// GetRegistryInfo gets the config.RegistryInfo field from the ConfigurationStruct.
	GetRegistryInfo() config.RegistryInfo

	// GetInsecureSecrets gets the config.InsecureSecrets field from the ConfigurationStruct.
	GetInsecureSecrets() config.InsecureSecrets

	// GetTelemetryInfo gets the config.Telemetry section from the ConfigurationStruct
	GetTelemetryInfo() *config.TelemetryInfo
}

Configuration interface provides an abstraction around a configuration struct.

type CredentialsProvider

type CredentialsProvider interface {
	// GetDatabaseCredentials retrieves database credentials.
	GetDatabaseCredentials(database config.Database) (config.Credentials, error)
}

CredentialsProvider interface provides an abstraction for obtaining credentials.

type MetricsManager added in v2.2.0

type MetricsManager interface {
	// ResetInterval resets the interval between reporting the current metrics
	ResetInterval(interval time.Duration)
	// Register registers a go-metrics metric item such as a Counter
	Register(name string, item interface{}, tags map[string]string) error
	// Unregister unregisters a go-metrics metric item such as a Counter
	Unregister(name string)
	// Run starts the collection of metrics
	Run(ctx context.Context, wg *sync.WaitGroup)
	// GetCounter retrieves the specified registered Counter
	// Returns nil if named item not registered or not a Counter
	GetCounter(name string) gometrics.Counter
	// GetGauge retrieves the specified registered Gauge
	// Returns nil if named item not registered or not a Gauge
	GetGauge(name string) gometrics.Gauge
	// GetGaugeFloat64 retrieves the specified registered GaugeFloat64
	// Returns nil if named item not registered or not a GaugeFloat64
	GetGaugeFloat64(name string) gometrics.GaugeFloat64
	// GetTimer retrieves the specified registered Timer
	// Returns nil if named item not registered or not a Timer
	GetTimer(name string) gometrics.Timer
}

MetricsManager manages a services metrics

type MetricsReporter added in v2.2.0

type MetricsReporter interface {
	Report(registry gometrics.Registry, metricTags map[string]map[string]string) error
}

MetricsReporter reports the metrics

type SecretProvider

type SecretProvider interface {
	// StoreSecret stores new secrets into the service's SecretStore at the specified path.
	StoreSecret(path string, secrets map[string]string) error

	// GetSecret retrieves secrets from the service's SecretStore at the specified path.
	GetSecret(path string, keys ...string) (map[string]string, error)

	// SecretsUpdated sets the secrets last updated time to current time.
	SecretsUpdated()

	// SecretsLastUpdated returns the last time secrets were updated
	SecretsLastUpdated() time.Time

	// GetAccessToken return an access token for the specified token type and service key.
	// Service key is use as the access token role which must have be previously setup.
	GetAccessToken(tokenType string, serviceKey string) (string, error)
}

SecretProvider defines the contract for secret provider implementations that allow secrets to be retrieved/stored from/to a services Secret Store.

type UpdatableConfig

type UpdatableConfig interface {
	// UpdateFromRaw converts configuration received from the Configuration Provider to a service-specific
	// configuration struct which is then used to overwrite the service's existing configuration struct.
	UpdateFromRaw(rawConfig interface{}) bool
}

UpdatableConfig interface allows service to have their custom configuration populated from configuration stored in the Configuration Provider (aka Consul). A service using custom configuration must implement this interface on the custom configuration, even if not using Configuration Provider. If not using the Configuration Provider it can have dummy implementations of this interface.

type WritableConfig

type WritableConfig interface {
	// UpdateWritableFromRaw converts updated configuration received from the Configuration Provider to a
	// service-specific struct that is being watched for changes by the Configuration Provider.
	// The changes are used to overwrite the service's existing configuration's watched struct.
	UpdateWritableFromRaw(rawWritableConfig interface{}) bool
}

WritableConfig allows service to listen for changes from the Configuration Provider and have the configuration updated when the changes occur

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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