appconfig

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package appconfig loads configuration from AWS AppConfig.

It requires following permissions to access AWS AppConfig:

  • appconfig:StartConfigurationSession
  • appconfig:GetLatestConfiguration

If change notification is enabled, it also requires following permissions:

  • appconfig:GetApplication
  • appconfig:GetEnvironment

Change notification

By default, it periodically polls the configuration only. It also listens to change events by register it to SNS notifier with one of following extensions:

Only ON_DEPLOYMENT_ROLLED_BACK events trigger polling the configuration and other type of events are ignored.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppConfig

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

AppConfig is a Provider that loads configuration from AWS AppConfig.

To create a new AppConfig, call New.

func New

func New(application, environment, profile string, opts ...Option) *AppConfig

New creates an AppConfig with the given application (ID or Name), environment (ID or Name), profile (ID or Name) and Option(s).

func (*AppConfig) Load

func (a *AppConfig) Load() (map[string]any, error)

func (*AppConfig) OnEvent added in v1.1.0

func (a *AppConfig) OnEvent(msg []byte) error

func (*AppConfig) Status added in v0.8.0

func (a *AppConfig) Status(onStatus func(bool, error))

func (*AppConfig) String

func (a *AppConfig) String() string

func (*AppConfig) Watch

func (a *AppConfig) Watch(ctx context.Context, onChange func(map[string]any)) error

type Option

type Option func(options *options)

Option configures the a AppConfig with specific options.

func WithAWSConfig

func WithAWSConfig(config aws.Config) Option

WithAWSConfig provides the AWS Config for the AWS SDK.

By default, it loads the default AWS Config.

func WithPollInterval

func WithPollInterval(interval time.Duration) Option

WithPollInterval provides the interval for polling the configuration. The minimum interval required by AWS AppConfig SDK is 15 seconds.

The default interval is 1 minute.

func WithUnmarshal

func WithUnmarshal(unmarshal func([]byte, any) error) Option

WithUnmarshal provides the function used to parses the configuration. The unmarshal function must be able to unmarshal the configuration into a map[string]any.

The default function is json.Unmarshal.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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