Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Origin/idempotency core #5

Merged
merged 16 commits into from
Jan 26, 2023
Merged

Origin/idempotency core #5

merged 16 commits into from
Jan 26, 2023

Conversation

KevenFuentes9
Copy link
Collaborator

Description of your changes

How to verify this change

Related issues, RFCs

Issue number:

PR status

Is this ready for review?: NO
Is it a breaking change?: NO

Checklist

  • My changes meet the tenets criteria
  • I have performed a self-review of my own code
  • I have commented my code where necessary, particularly in areas that should be flagged with a TODO, or hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding changes to the examples
  • My changes generate no new warnings
  • The code coverage hasn't decreased
  • I have added tests that prove my change is effective and works
  • New and existing unit tests pass locally and in Github Actions
  • Any dependent changes have been merged and published in downstream module
  • The PR title follows the conventional commit semantics

Breaking change checklist

  • I have documented the migration process
  • I have added, implemented necessary warnings (if it can live side by side)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

public constructor(private functiontoMakeIdempotent: AnyFunctionWithRecord<U>, private functionPayloadToBeHashed: unknown,
private idempotencyOptions: IdempotencyOptions, private fullFunctionPayload: Record<string, any>) {}

public determineResultFromIdempotencyRecord(idempotencyRecord: IdempotencyRecord): Promise<U> | U{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be work for another PR, but we need to add comments to the public-facing methods that document how we expect the methods to be used

private idempotencyOptions: IdempotencyOptions, private fullFunctionPayload: Record<string, any>) {}

public determineResultFromIdempotencyRecord(idempotencyRecord: IdempotencyRecord): Promise<U> | U{
if (idempotencyRecord.getStatus() === IdempotencyRecordStatus.EXPIRED) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice the Python version has comments explaining why this is an inconsistent state. It may be helpful to add similar comments here for context.

throw new IdempotencyAlreadyInProgressError(`There is already an execution in progress with idempotency key: ${idempotencyRecord.idempotencyKey}`);
} else {
// Currently recalling the method as this fulfills FR1. FR3 will address using the previously stored value https://github.com/awslabs/aws-lambda-powertools-typescript/issues/447
return this.functiontoMakeIdempotent(this.fullFunctionPayload);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this achieve idempotency (FR1) or does it just prevent concurrent calls from executing the same code?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main question I have is: should we recall the method or should we just not return a response. I don't recall whether we discussed this earlier.


export {
AnyFunction
// AnyFunction,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should be removed in the future.

Copy link
Owner

@jeffrey-baker-vg jeffrey-baker-vg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still curious about the answers to my question, but nothing here should stop it in my opinion

@KevenFuentes9 KevenFuentes9 merged commit d0d0574 into main Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants