Skip to content

Commit 2a7fd30

Browse files
authored
Revert "feat(idempotency): add idempotency decorator (#1723)"
This reverts commit d138673.
1 parent d138673 commit 2a7fd30

File tree

8 files changed

+1
-1121
lines changed

8 files changed

+1
-1121
lines changed

Diff for: docs/snippets/idempotency/idempotentDecoratorBase.ts

-28
This file was deleted.

Diff for: docs/utilities/idempotency.md

-16
Original file line numberDiff line numberDiff line change
@@ -160,22 +160,6 @@ When using `makeIdempotent` on arbitrary functions, you can tell us which argume
160160

161161
The function this example has two arguments, note that while wrapping it with the `makeIdempotent` high-order function, we specify the `dataIndexArgument` as `1` to tell the decorator that the second argument is the one that contains the data we should use to make the function idempotent. Remember that arguments are zero-indexed, so the first argument is `0`, the second is `1`, and so on.
162162

163-
### Idempotent Decorator
164-
165-
You can also use the `@idempotent` decorator to make your Lambda handler idempotent, similar to the `makeIdempotent` function wrapper.
166-
167-
=== "index.ts"
168-
169-
```typescript hl_lines="17"
170-
--8<-- "docs/snippets/idempotency/idempotentDecoratorBase.ts"
171-
```
172-
173-
=== "types.ts"
174-
175-
```typescript
176-
177-
You can use the decorator on your Lambda handler or on any function that returns a response to make it idempotent. This is useful when you want to make a specific logic idempotent, for example when your Lambda handler performs multiple side effects and you only want to make a specific one idempotent.
178-
The configuration options for the `@idempotent` decorator are the same as the ones for the `makeIdempotent` function wrapper.
179163

180164
### MakeHandlerIdempotent Middy middleware
181165

Diff for: packages/idempotency/README.md

+1-65
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ You can use the package in both TypeScript and JavaScript code bases.
99
- [Key features](#key-features)
1010
- [Usage](#usage)
1111
- [Function wrapper](#function-wrapper)
12-
- [Decorator](#decorator)
1312
- [Middy middleware](#middy-middleware)
1413
- [DynamoDB persistence layer](#dynamodb-persistence-layer)
1514
- [Contribute](#contribute)
@@ -25,7 +24,7 @@ You can use the package in both TypeScript and JavaScript code bases.
2524
## Intro
2625

2726
This package provides a utility to implement idempotency in your Lambda functions.
28-
You can either use it to wrap a function, decorate a function, or as Middy middleware to make your AWS Lambda handler idempotent.
27+
You can either use it to wrap a function, or as Middy middleware to make your AWS Lambda handler idempotent.
2928

3029
The current implementation provides a persistence layer for Amazon DynamoDB, which offers a variety of configuration options. You can also bring your own persistence layer by extending the `BasePersistenceLayer` class.
3130

@@ -164,69 +163,6 @@ export const handler = makeIdempotent(myHandler, {
164163

165164
Check the [docs](https://docs.powertools.aws.dev/lambda/typescript/latest/utilities/idempotency/) for more examples.
166165

167-
### Decorator
168-
169-
You can make any function idempotent, and safe to retry, by decorating it using the `@idempotent` decorator.
170-
171-
```ts
172-
import { idempotent } from '@aws-lambda-powertools/idempotency';
173-
import { LambdaInterface } from '@aws-lambda-powertools/commons';
174-
import { DynamoDBPersistenceLayer } from '@aws-lambda-powertools/idempotency/dynamodb';
175-
import type { Context, APIGatewayProxyEvent } from 'aws-lambda';
176-
177-
const persistenceStore = new DynamoDBPersistenceLayer({
178-
tableName: 'idempotencyTableName',
179-
});
180-
181-
class MyHandler extends LambdaInterface {
182-
@idempotent({ persistenceStore: dynamoDBPersistenceLayer })
183-
public async handler(
184-
event: APIGatewayProxyEvent,
185-
context: Context
186-
): Promise<void> {
187-
// your code goes here here
188-
}
189-
}
190-
191-
const handlerClass = new MyHandler();
192-
export const handler = handlerClass.handler.bind(handlerClass);
193-
```
194-
195-
Using the same decorator, you can also make any other arbitrary function idempotent.
196-
197-
```ts
198-
import { idempotent } from '@aws-lambda-powertools/idempotency';
199-
import { LambdaInterface } from '@aws-lambda-powertools/commons';
200-
import { DynamoDBPersistenceLayer } from '@aws-lambda-powertools/idempotency/dynamodb';
201-
import type { Context } from 'aws-lambda';
202-
203-
const persistenceStore = new DynamoDBPersistenceLayer({
204-
tableName: 'idempotencyTableName',
205-
});
206-
207-
class MyHandler extends LambdaInterface {
208-
209-
public async handler(
210-
event: unknown,
211-
context: Context
212-
): Promise<void> {
213-
for(const record of event.Records) {
214-
await this.processIdempotently(record);
215-
}
216-
}
217-
218-
@idempotent({ persistenceStore: dynamoDBPersistenceLayer })
219-
private async process(record: unknown): Promise<void> {
220-
// process each code idempotently
221-
}
222-
}
223-
224-
const handlerClass = new MyHandler();
225-
export const handler = handlerClass.handler.bind(handlerClass);
226-
```
227-
228-
The decorator configuration options are identical with the ones of the `makeIdempotent` function. Check the [docs](https://docs.powertools.aws.dev/lambda/typescript/latest/utilities/idempotency/) for more examples.
229-
230166
### Middy middleware
231167

232168
If instead you use Middy, you can use the `makeHandlerIdempotent` middleware. When using the middleware your Lambda handler becomes idempotent.

Diff for: packages/idempotency/src/idempotencyDecorator.ts

-69
This file was deleted.

Diff for: packages/idempotency/src/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export * from './errors';
22
export * from './IdempotencyConfig';
33
export * from './makeIdempotent';
4-
export * from './idempotencyDecorator';
54
export { IdempotencyRecordStatus } from './constants';

Diff for: packages/idempotency/tests/e2e/idempotentDecorator.test.FunctionCode.ts

-164
This file was deleted.

0 commit comments

Comments
 (0)