Skip to content

Commit

Permalink
Make burst defaults to null & make it a last parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
KiKoS0 committed Sep 1, 2024
1 parent 9c64f59 commit a583176
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public InngestFunctionConfigBuilder config(InngestFunctionConfigBuilder builder)
.id("ThrottledFunction")
.name("Throttled Function")
.triggerEvent("test/throttled")
.throttle(1, Duration.ofSeconds(10), 1, "throttled");
.throttle(1, Duration.ofSeconds(10), "throttled", 1);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,17 @@ class InngestFunctionConfigBuilder {
* @param limit The total number of runs allowed to start within the given period. The limit is applied evenly over the period.
* @param period The period of time for the rate limit. Run starts are evenly spaced through the given period.
* The minimum granularity is 1 second.
* @param burst The number of runs allowed to start in the given window in a single burst.
* A burst > 1 bypasses smoothing for the burst and allows many runs to start at once, if desired. Defaults to 1, which disables bursting.
* @param key An optional expression which returns a throttling key for controlling throttling.
* Every unique key is its own throttle limit. Event data may be used within this expression, eg "event.data.user_id".
* @param burst The number of runs allowed to start in the given window in a single burst.
* A burst > 1 bypasses smoothing for the burst and allows many runs to start at once, if desired. Defaults to 1, which disables bursting.
*/
@JvmOverloads
fun throttle(
limit: Int,
period: Duration,
burst: Int? = null,
key: String? = null,
burst: Int? = null,
): InngestFunctionConfigBuilder = apply { this.throttle = Throttle(limit, period, key, burst) }

private fun buildSteps(serveUrl: String): Map<String, StepConfig> {
Expand Down Expand Up @@ -245,7 +245,7 @@ internal data class Throttle
@Json(serializeNull = false)
val key: String? = null,
@Json(serializeNull = false)
val burst: Int? = 1,
val burst: Int? = null,
)

internal data class BatchEvents
Expand Down

0 comments on commit a583176

Please sign in to comment.