-
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
Validate concurrency key is required when scope is account or env #81
Conversation
ConcurrencyScope.ENVIRONMENT -> if (key == null) throw InngestInvalidConfigurationException("Concurrency key required with environment scope") | ||
ConcurrencyScope.ACCOUNT -> if (key == null) throw InngestInvalidConfigurationException("Concurrency key required with account scope") |
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.
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.
i see yeah that makes sense, the js sdk isn't preventing this either but it could probably prevent it better with a union type instead of exceptions.
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.
yeah I was considering a similar idea but it seemed more cumbersome to do in kotlin, so I went with the validation method
} catch (e: Exception) { | ||
throw InngestInvalidConfigurationException( | ||
"Function id must be configured via builder: ${this.javaClass.name}", | ||
) | ||
} |
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.
this is unnecessary because it's being thrown here
inngest-kt/inngest/src/main/kotlin/com/inngest/InngestFunctionConfigBuilder.kt
Lines 210 to 212 in 70ac4e3
if (id == null) { | |
throw InngestInvalidConfigurationException("Function id must be configured via builder") | |
} |
and catch (e: Exception)
was swallowing other InngestInvalidConfigurationException
s and rethrowing them for the wrong reason
- If concurrency scope is account or env, validate that key is provided - Also added check that at most 2 concurrency options are provided - Removed exception catch in InngestFunction.kt since it is swallowing other InngestInvalidConfigurationExceptions - Add key for RestoreFromGlacier example
a458849
to
b950969
Compare
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.
looks good
ConcurrencyScope.FUNCTION -> {} | ||
null -> {} |
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.
nit: can be a single else clause unless you wanted all expected values explicit.
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.
yeah I was thinking of making it exhaustive but I could be convinced either way
if (this.concurrency == null) { | ||
this.concurrency = mutableListOf(c) | ||
} else if (this.concurrency!!.size == 2) { |
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.
Now that i think of it Kotlin not inferring the non-null type is because different threads could mutate it to null
between the null
check and accessing it right? Similar to your other stepIdsToSeenCount[id]
being still nullable as well.
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.
huh interesting I was wondering why the compiler was realizing it wasn't null but that makes sense. Do you know a way around this? I tried wrapping this with a synchronized
block and it doesn't seem to help 🤔
@KiKoS0 going to merge as is but if you have additional opinions on the |
Summary
other InngestInvalidConfigurationExceptions
Checklist
Related