-
Notifications
You must be signed in to change notification settings - Fork 3
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 cancelOn configuration #82
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
albertchae
force-pushed
the
albert/inn-3335-cancelOn-configuration
branch
from
September 11, 2024 07:53
4924958
to
d32b38f
Compare
albertchae
commented
Sep 11, 2024
.cancelOn("cancel", null, Duration.ofSeconds(6000)) | ||
.build("app-id", "https://mysite.com/api/inngest") | ||
|
||
assertEquals<List<Cancellation>?>(listOf(Cancellation("cancel", null, "\"6000s\"")), durationConfig.cancel) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The klaxon serializer for this adds inner quotes to the value
override fun toJson(value: Any): String = """"${(value as Duration).seconds}s"""" |
albertchae
requested review from
djfarrelly,
darwin67,
jpwilliams and
tonyhb
as code owners
September 11, 2024 08:08
albertchae
force-pushed
the
albert/inn-3335-cancelOn-configuration
branch
2 times, most recently
from
September 13, 2024 00:49
b352beb
to
b4d1510
Compare
- followed similar pattern to `InngestFunctionTriggers` but didn't reuse that class for a few reasons - `if` concept is similar but for triggers it gets serialized as `expression` but is `if` for cancel - `timeout` is only used by cancel and not for triggers and vice versa with `cron`, so it seems the `InngestFunctionTrigger` class's fields would be sparsely populated for all the concrete cases and not provide too much value in sharing code - While I like the idea of calling the "thing" that sets off Cancel as "CancelTrigger" or "CancellationTrigger", I thought this could be confusing since triggers are their own key under configuration https://github.com/inngest/inngest/blame/0ac11f2c312c066e517e53749052dd89fd2926ba/docs/SDK_SPEC.md#L478 - `Cancellation` name avoided "trigger" for reason above and followed pattern in https://github.com/inngest/inngest-js/blob/0e51903d5968a7287dd7e518bd5cc8acec3e6f3e/packages/inngest/src/types.ts#L901 - I originally was going to implement with `match` as well per https://www.inngest.com/docs/reference/typescript/functions/cancel-on, but I saw later that it's currently deprecated so I stuck to `if` only. https://github.com/inngest/inngest-js/blob/0e51903d5968a7287dd7e518bd5cc8acec3e6f3e/packages/inngest/src/types.ts#L946 - Per the flexibility of timeout in https://github.com/inngest/inngest/blob/0ac11f2c312c066e517e53749052dd89fd2926ba/docs/SDK_SPEC.md?plain=1#L580-L583 The type for timeout is either `Duration` or `Instant`.
albertchae
force-pushed
the
albert/inn-3335-cancelOn-configuration
branch
from
September 13, 2024 01:06
b4d1510
to
9698f55
Compare
KiKoS0
approved these changes
Sep 13, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice work, i think it looks great
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
InngestFunctionTriggers
but didn't reusethat class for a few reasons
if
concept is similar but for triggers it gets serialized asexpression
but isif
for canceltimeout
is only used by cancel and not for triggers and vice versa withcron
, so it seems theInngestFunctionTrigger
class's fields would be sparsely populated for all the concrete cases and not provide too much value in sharing codeCancellation
name avoided "trigger" for reason above and followed pattern in https://github.com/inngest/inngest-js/blob/0e51903d5968a7287dd7e518bd5cc8acec3e6f3e/packages/inngest/src/types.ts#L901match
as well per https://www.inngest.com/docs/reference/typescript/functions/cancel-on, but I saw later that it's currently deprecated so I stuck toif
only.Duration
orInstant
.Checklist
Related