Documentation
¶
Overview ¶
Package appconfig retrieves configuration through the AWS AppConfig Data API.
New wraps an application-owned SDK Client with application and environment names in Config. Provider.Get uses a configuration profile name and GetOptions for session selectors, cache age and transforms.
Polling lifecycle ¶
The provider manages configuration session tokens and serializes polling for each session. An unchanged service response retains the previous configuration. Reuse the provider across Lambda invocations so token and cache state survive. Provider.ClearCache invalidates local cached values.
For the local AppConfig Agent or Lambda extension HTTP interface, use the sibling appconfigagent package instead of this direct SDK adapter.
For usage and compatibility details, see the user guide.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAppConfig ¶
GetAppConfig uses the application and environment from the first successful initialization. Use separate providers for different applications or environments.
Types ¶
type Client ¶
type Client interface {
StartConfigurationSession(context.Context, *sdk.StartConfigurationSessionInput, ...func(*sdk.Options)) (*sdk.StartConfigurationSessionOutput, error)
GetLatestConfiguration(context.Context, *sdk.GetLatestConfigurationInput, ...func(*sdk.Options)) (*sdk.GetLatestConfigurationOutput, error)
}
type DefaultOptions ¶
type DefaultOptions struct {
GetOptions
Application, Environment string
}
type GetOptions ¶
type GetOptions struct {
parameters.Options
SDKOptions *sdk.StartConfigurationSessionInput
}
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
func (*Provider) ClearCache ¶
func (p *Provider) ClearCache()
ClearCache clears transformed values. Session tokens and last known configuration remain available because an unchanged AppConfig response has an empty body.
func (*Provider) Get ¶
Example ¶
This example requires AWS credentials and an existing AppConfig deployment.
package main
import (
"context"
"github.com/aws/aws-sdk-go-v2/config"
sdk "github.com/aws/aws-sdk-go-v2/service/appconfigdata"
"github.com/rambow-cloud/powertools-lambda-go/parameters/appconfig"
)
func main() {
ctx := context.Background()
cfg, err := config.LoadDefaultConfig(ctx)
if err != nil {
panic(err)
}
provider, err := appconfig.New(sdk.NewFromConfig(cfg), appconfig.Config{
Application: "example", Environment: "development",
})
if err != nil {
panic(err)
}
value, err := provider.Get(ctx, "features", appconfig.GetOptions{})
if err != nil {
panic(err)
}
_ = value // Reuse the provider so session tokens survive warm invocations.
}
Output: