From a3dc079bbda74f96078428959eef007a34a28dc6 Mon Sep 17 00:00:00 2001 From: Tyler Arehart Date: Mon, 11 Dec 2023 11:53:06 -0800 Subject: [PATCH] Improving documentation. --- README.md | 17 +++++++++++++++++ examples/infinitePoller.ts | 2 ++ 2 files changed, 19 insertions(+) diff --git a/README.md b/README.md index 89b9d91..42b49b5 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,26 @@ A wrapper around @aws-sdk/client-appconfigdata to provide background polling and caching. +Although AWS seems to recommend their [simplified retrieval methods](https://docs.aws.amazon.com/appconfig/latest/userguide/appconfig-retrieving-simplified-methods.html) for fetching AppConfig, i.e. running an agent in a separate process, you may prefer to use this library: + +- You don't need to set up a lambda extension. +- You easily get parity between your local development server and prod. +- The parsed version of your config is conveniently cached. +- You get convenient reporting of transient errors while the library works in the background to recover. + ## Usage Initialize: ```typescript +import { AppConfigDataClient } from '@aws-sdk/client-appconfigdata'; +import { Poller } from 'aws-appconfig-poller'; + +const dataClient = new AppConfigDataClient({ + // Set up credentials, region, etc, as necessary. + credentials: undefined, +}); + const poller = new Poller({ dataClient: dataClient, sessionConfig: { @@ -36,6 +51,8 @@ Fetch: const { latestValue } = poller.getConfigurationObject(); ``` +For full working code, see examples/infinitePoller.ts. + ## Error handling A few things can go wrong when polling for AppConfig, such as: diff --git a/examples/infinitePoller.ts b/examples/infinitePoller.ts index ab45595..96a2ddf 100644 --- a/examples/infinitePoller.ts +++ b/examples/infinitePoller.ts @@ -71,6 +71,8 @@ if (!isInitiallySuccessful) { console.log('Connection succeeded at:', new Date()); +// Normally you would not use setInterval in your app, this is just to help us +// periodically log the state of the configuration object to prove it's working. setInterval(() => { const obj = poller.getConfigurationObject(); console.log('Current config entry', obj);