Skip to content

Commit

Permalink
chore: add retry information to readme (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhamzeh authored Apr 4, 2024
2 parents 7676cc6 + 1875abb commit ab77704
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ This is an autogenerated JavaScript SDK for OpenFGA. It provides a wrapper aroun
- [Assertions](#assertions)
- [Read Assertions](#read-assertions)
- [Write Assertions](#write-assertions)
- [Retries](#retries)
- [API Endpoints](#api-endpoints)
- [Models](#models)
- [Contributing](#contributing)
Expand Down Expand Up @@ -619,6 +620,26 @@ const response = await fgaClient.writeAssertions([{
```


### Retries

By default API requests are retried up to 15 times on 429 and 5xx errors and credential requests are retried to 3 times on 429 and 5xx errors. In both instances they will wait a minimum of 100 milliseconds between requests and up to a maximum of

In order to change the behavior for API requests, pass a `retryParams` object in the `OpenFgaClient` constructor with a `maxRetry` property to control the amount of retries and a `minWaitInMs` to control the minimum wait time between retried requests.

```javascript
const { OpenFgaClient } = require('@openfga/sdk'); // OR import { OpenFgaClient } from '@openfga/sdk';

const fgaClient = new OpenFgaClient({
apiUrl: process.env.FGA_API_URL, // required
storeId: process.env.FGA_STORE_ID, // not needed when calling `CreateStore` or `ListStores`
authorizationModelId: process.env.FGA_AUTHORIZATION_MODEL_ID, // Optional, can be overridden per request
retryParams: {
maxRetry: 3, // retry up to 3 times on API requests
minWaitInMs: 250 // wait a minimum of 250 milliseconds between requests
}
});
```

### API Endpoints

| Method | HTTP request | Description |
Expand Down

0 comments on commit ab77704

Please sign in to comment.