-
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #607 from hexagonkt/develop
Update handlers
- Loading branch information
Showing
32 changed files
with
250 additions
and
243 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Check usage information at: http://hexagonkt.com/gradle/#jmh | ||
*/ | ||
|
||
apply(plugin: "me.champeau.jmh") | ||
|
||
tasks.compileJmhKotlin.kotlinOptions.jvmTarget = tasks.compileKotlin.kotlinOptions.jvmTarget | ||
tasks.compileJmhKotlin.kotlinOptions.apiVersion = tasks.compileKotlin.kotlinOptions.apiVersion | ||
|
||
jmh { | ||
final String jhmVersion = findProperty("jhmVersion") ?: "1.36" | ||
|
||
jmhVersion.set(jhmVersion) | ||
benchmarkMode.set(["thrpt"]) | ||
|
||
iterations.set(10) | ||
batchSize.set(1) | ||
fork.set(1) | ||
operationsPerInvocation.set(5) | ||
timeOnIteration.set("1s") | ||
|
||
warmup.set("1s") | ||
warmupBatchSize.set(5) | ||
warmupIterations.set(1) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
# TODO Use Gradle 8 when Dokka support it | ||
#distributionUrl=https://services.gradle.org/distributions/gradle-8.0.1-all.zip | ||
distributionUrl=https://services.gradle.org/distributions/gradle-7.6.1-all.zip | ||
distributionUrl=https://services.gradle.org/distributions/gradle-8.0.2-all.zip | ||
networkTimeout=10000 | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
|
||
plugins { | ||
id("java-library") | ||
id("me.champeau.jmh") | ||
} | ||
|
||
apply(from = "../gradle/kotlin.gradle") | ||
apply(from = "../gradle/publish.gradle") | ||
apply(from = "../gradle/dokka.gradle") | ||
apply(from = "../gradle/jmh.gradle") | ||
|
||
description = "Handlers to be applied on events processing." |
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
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
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
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
15 changes: 12 additions & 3 deletions
15
handlers/src/main/kotlin/com/hexagonkt/handlers/FilterHandler.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,15 @@ | ||
package com.hexagonkt.handlers | ||
|
||
data class FilterHandler<T : Any>( | ||
override val predicate: Predicate<T> = { true }, | ||
override val callback: Callback<T>, | ||
) : Handler<T> | ||
override val predicate: (Context<T>) -> Boolean = { true }, | ||
override val callback: (Context<T>) -> Context<T>, | ||
) : Handler<T> { | ||
|
||
override fun process(context: Context<T>): Context<T> = | ||
try { | ||
callback(context) | ||
} | ||
catch (e: Exception) { | ||
context.with(exception = e) | ||
} | ||
} |
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
This file was deleted.
Oops, something went wrong.
11 changes: 5 additions & 6 deletions
11
handlers/src/main/kotlin/com/hexagonkt/handlers/OnHandler.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
package com.hexagonkt.handlers | ||
|
||
data class OnHandler<T : Any>( | ||
override val predicate: Predicate<T> = { true }, | ||
val beforeCallback: Callback<T>, | ||
override val predicate: (Context<T>) -> Boolean = { true }, | ||
override val callback: (Context<T>) -> Context<T>, | ||
) : Handler<T> { | ||
|
||
override val callback: Callback<T> = { | ||
override fun process(context: Context<T>): Context<T> = | ||
try { | ||
beforeCallback(it).next() | ||
callback(context).next() | ||
} | ||
catch (e: Exception) { | ||
it.with(exception = e).next() | ||
context.with(exception = e).next() | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.