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

Add idempotency configuration #80

Merged
merged 1 commit into from
Sep 10, 2024

Conversation

albertchae
Copy link
Collaborator

@albertchae albertchae commented Sep 9, 2024

Summary

Add idempotency as a top level optional string key to function config

Copied doc from
https://github.com/inngest/inngest/blob/6594ccb692121bfe62b11676fe002416df13300b/docs/SDK_SPEC.md?plain=1#L534-L538

https://www.inngest.com/docs/guides/handling-idempotency#at-the-function-level-the-consumer

Ideally the integration test could use an observable side effect to see
that the function only ran once, but we are also able to use the return
value from the dev server to check that the second run was ignored.

The integration test validates idempotency by

  • checking an observable side effect, in this case incrementing a static counter variable
  • check that the second run of the same idempotency was ignored by the dev server

Checklist

  • Update documentation
  • Added unit/integration tests

Related

Copy link

linear bot commented Sep 9, 2024

@albertchae albertchae marked this pull request as ready for review September 9, 2024 14:03
@@ -82,8 +82,11 @@ internal class InternalFunctionConfig
val throttle: Throttle? = null,
@Json(serializeNull = false)
val debounce: Debounce? = null,
@Json(serializeNull = false)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I missed this when resolving merge conflicts for #71

Copy link
Collaborator

@KiKoS0 KiKoS0 left a comment

Choose a reason for hiding this comment

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

An observable side effect could a static count on the InngestFunction right? I think this is good too though

Copied doc from
https://github.com/inngest/inngest/blob/6594ccb692121bfe62b11676fe002416df13300b/docs/SDK_SPEC.md?plain=1#L534-L538

https://www.inngest.com/docs/guides/handling-idempotency#at-the-function-level-the-consumer

The integration test validates idempotency by
- checking an observable side effect, in this case incrementing a static
  counter variable
- check that the second run of the same idempotency was ignored by the
  dev server
@albertchae albertchae force-pushed the albert/inn-3331-add-idempotency-configuration branch from c025fbf to 0bbeb8c Compare September 10, 2024 04:46
@albertchae
Copy link
Collaborator Author

An observable side effect could a static count on the InngestFunction right? I think this is good too thought

I thought I tried that (you'll notice I even named my test step increment-count in https://github.com/inngest/inngest-kt/pull/80/files#diff-40149b2f8044c7de14c386ecf2cab937d2782dfb3766202ce817702f66b1e249R20) but I must have done something wrong, because I just tried again and it seems to work

@albertchae albertchae merged commit bf5da4f into main Sep 10, 2024
9 checks passed
@albertchae albertchae deleted the albert/inn-3331-add-idempotency-configuration branch September 10, 2024 04:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants