Skip to content

Commit

Permalink
Removed retryability implementation (AWS SDK provides it)
Browse files Browse the repository at this point in the history
  • Loading branch information
squidfunk committed Aug 7, 2018
1 parent b53cf0e commit 31617d2
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 226 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
isotopes-0.5.0 (2018-08-07)

* Removed retryability implementation (AWS SDK provides it)

isotopes-0.4.2 (2018-08-07)

* Fixed failing delete operation without attribute names
Expand Down
11 changes: 1 addition & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ indexing and querying of JSON documents in [AWS SimpleDB][1] using SQL queries.
*Isotopes* is just perfect for small to medium-sized datasets, especially for
indexing data from other AWS services for flexible querying. It can easily be
run from within [AWS Lambda][2] and reduces the boilerplate that is necessary
to interface with SimpleDB to an absolute minimum. It is also fault-tolerant
and will retry failed requests using a configurable strategy.
to interface with SimpleDB to an absolute minimum.

[1]: https://aws.amazon.com/de/simpledb/
[2]: https://aws.amazon.com/de/lambda/
Expand Down Expand Up @@ -328,11 +327,6 @@ enables configuration of the underlying SimpleDB client.
| `options.format?.multiple?` | `boolean` | `true` | Multi-attribute values for arrays |
| `options.client?` | `IsotopeClientOptions` | `"json"` | SimpleDB client options |
| `options.client?.consistent?` | `boolean` | `false` | Whether to use consistent reads |
| `options.client?.retry?` | `OperationOptions` | `false` | Retry strategy options |

Under the hood, *Isotopes* uses [retry][7], a library implementing exponential
backoff as a retry strategy. [`OperationOptions`][8] is the input parameter
for `retry.operation` which is used to implement retryability.

**Example**

Expand All @@ -343,9 +337,6 @@ const isotope = new Isotope<T>({
})
```

[7]: https://github.com/tim-kos/node-retry
[8]: https://github.com/tim-kos/node-retry#retryoperationoptions

#### `isotope.create(): Promise<void>`

Creates the underlying SimpleDB domain.
Expand Down
12 changes: 1 addition & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "isotopes",
"version": "0.4.2",
"version": "0.5.0",
"description": "Serverless and typed object store built on top of AWS SimpleDB",
"keywords": [
"aws",
Expand Down Expand Up @@ -34,9 +34,7 @@
"watch": "make watch"
},
"dependencies": {
"@types/retry": "^0.10.2",
"lodash": "^4.17.10",
"retry": "^0.12.0",
"squel": "^5.12.2"
},
"devDependencies": {
Expand Down
88 changes: 35 additions & 53 deletions src/isotopes/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@

import { SimpleDB } from "aws-sdk"
import { castArray, toPairs } from "lodash/fp"
import { OperationOptions } from "retry"

import { IsotopeDictionary } from "../format"
import { retryable } from "./retryable"

/* ----------------------------------------------------------------------------
* Types
Expand All @@ -36,7 +34,6 @@ import { retryable } from "./retryable"
*/
export interface IsotopeClientOptions {
consistent?: boolean /* Whether to use consistent reads */
retry?: OperationOptions /* Retry strategy options */
}

/**
Expand All @@ -61,18 +58,9 @@ export interface IsotopeClientItemList {

/**
* Default client options
*
* We're not using the exponential backoff strategy (as recommended) due to the
* observations made in this article: https://bit.ly/2AJQiNV
*/
const defaultOptions: Required<IsotopeClientOptions> = {
consistent: false,
retry: {
minTimeout: 100,
maxTimeout: 250,
retries: 3,
factor: 1
}
consistent: false
}

/* ----------------------------------------------------------------------------
Expand Down Expand Up @@ -159,10 +147,9 @@ export class IsotopeClient {
* @return Promise resolving with no result
*/
public async create(): Promise<void> {
await retryable(() =>
this.simpledb.createDomain({
DomainName: this.domain
}).promise(), this.options.retry)
await this.simpledb.createDomain({
DomainName: this.domain
}).promise()
}

/**
Expand All @@ -171,10 +158,9 @@ export class IsotopeClient {
* @return Promise resolving with no result
*/
public async destroy(): Promise<void> {
await retryable(() =>
this.simpledb.deleteDomain({
DomainName: this.domain
}).promise(), this.options.retry)
await this.simpledb.deleteDomain({
DomainName: this.domain
}).promise()
}

/**
Expand All @@ -188,13 +174,12 @@ export class IsotopeClient {
public async get(
id: string, names?: string[]
): Promise<IsotopeClientItem | undefined> {
const { Attributes } = await retryable(() =>
this.simpledb.getAttributes({
DomainName: this.domain,
ItemName: id,
AttributeNames: names,
ConsistentRead: this.options.consistent
}).promise(), this.options.retry)
const { Attributes } = await this.simpledb.getAttributes({
DomainName: this.domain,
ItemName: id,
AttributeNames: names,
ConsistentRead: this.options.consistent
}).promise()

/* Item not found */
if (!Attributes)
Expand All @@ -218,12 +203,11 @@ export class IsotopeClient {
public async put(
id: string, attrs: IsotopeDictionary
): Promise<void> {
await retryable(() =>
this.simpledb.putAttributes({
DomainName: this.domain,
ItemName: id,
Attributes: mapDictionaryToAttributes(attrs)
}).promise(), this.options.retry)
await this.simpledb.putAttributes({
DomainName: this.domain,
ItemName: id,
Attributes: mapDictionaryToAttributes(attrs)
}).promise()
}

/**
Expand All @@ -237,19 +221,18 @@ export class IsotopeClient {
public async delete(
id: string, names?: string[]
): Promise<void> {
await retryable(() =>
this.simpledb.deleteAttributes({
DomainName: this.domain,
ItemName: id,
...(names
? {
Attributes: names.map<SimpleDB.DeletableAttribute>(name => ({
Name: name
}))
}
: {}
)
}).promise(), this.options.retry)
await this.simpledb.deleteAttributes({
DomainName: this.domain,
ItemName: id,
...(names
? {
Attributes: names.map<SimpleDB.DeletableAttribute>(name => ({
Name: name
}))
}
: {}
)
}).promise()
}

/**
Expand All @@ -263,12 +246,11 @@ export class IsotopeClient {
public async select(
expr: string, next?: string
): Promise<IsotopeClientItemList> {
const { Items, NextToken } = await retryable(() =>
this.simpledb.select({
SelectExpression: expr,
NextToken: next,
ConsistentRead: this.options.consistent
}).promise(), this.options.retry)
const { Items, NextToken } = await this.simpledb.select({
SelectExpression: expr,
NextToken: next,
ConsistentRead: this.options.consistent
}).promise()

/* No items found */
if (!Items)
Expand Down
57 changes: 0 additions & 57 deletions src/isotopes/client/retryable/index.ts

This file was deleted.

92 changes: 0 additions & 92 deletions tests/suites/unit/isotopes/client/retryable/index.spec.ts

This file was deleted.

0 comments on commit 31617d2

Please sign in to comment.