Skip to content

Commit a3dc079

Browse files
committed
Improving documentation.
1 parent f88af6d commit a3dc079

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,26 @@
44

55
A wrapper around @aws-sdk/client-appconfigdata to provide background polling and caching.
66

7+
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:
8+
9+
- You don't need to set up a lambda extension.
10+
- You easily get parity between your local development server and prod.
11+
- The parsed version of your config is conveniently cached.
12+
- You get convenient reporting of transient errors while the library works in the background to recover.
13+
714
## Usage
815

916
Initialize:
1017

1118
```typescript
19+
import { AppConfigDataClient } from '@aws-sdk/client-appconfigdata';
20+
import { Poller } from 'aws-appconfig-poller';
21+
22+
const dataClient = new AppConfigDataClient({
23+
// Set up credentials, region, etc, as necessary.
24+
credentials: undefined,
25+
});
26+
1227
const poller = new Poller({
1328
dataClient: dataClient,
1429
sessionConfig: {
@@ -36,6 +51,8 @@ Fetch:
3651
const { latestValue } = poller.getConfigurationObject();
3752
```
3853

54+
For full working code, see examples/infinitePoller.ts.
55+
3956
## Error handling
4057

4158
A few things can go wrong when polling for AppConfig, such as:

examples/infinitePoller.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ if (!isInitiallySuccessful) {
7171

7272
console.log('Connection succeeded at:', new Date());
7373

74+
// Normally you would not use setInterval in your app, this is just to help us
75+
// periodically log the state of the configuration object to prove it's working.
7476
setInterval(() => {
7577
const obj = poller.getConfigurationObject();
7678
console.log('Current config entry', obj);

0 commit comments

Comments
 (0)