-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent users from enabling auto commit (#1290)
Zio-kafka applications always pre-fetch data so that user streams can process the data asynchronously. This is not compatible with auto commit. When auto commit is enabled, the consumer will automatically commit batches _before_ they are processed by the user streams. An unaware user might accidentally enable auto commit and lose data during rebalances. Solves #1289.
- Loading branch information
1 parent
fd40816
commit 092de53
Showing
3 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
zio-kafka-test/src/test/scala/zio/kafka/consumer/ConsumerSettingsSpec.scala
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,24 @@ | ||
package zio.kafka.consumer | ||
|
||
import zio._ | ||
import zio.kafka.ZIOSpecDefaultSlf4j | ||
import zio.test._ | ||
import zio.test.Assertion._ | ||
|
||
object ConsumerSettingsSpec extends ZIOSpecDefaultSlf4j { | ||
|
||
override def spec: Spec[TestEnvironment with Scope, Throwable] = | ||
suite("ConsumerSettingsSpec")( | ||
test("accepts no auto.commit") { | ||
ZIO.attempt(ConsumerSettings(List("host"))) *> assertCompletesZIO | ||
}, | ||
test("accepts disabled auto.commit") { | ||
ZIO.attempt(ConsumerSettings(List("host")).withProperty("enable.auto.commit", "false")) *> assertCompletesZIO | ||
}, | ||
test("rejects auto.commit") { | ||
val settings = ZIO.attempt(ConsumerSettings(List("host")).withProperty("enable.auto.commit", "true")).exit | ||
assertZIO(settings)(failsWithA[IllegalArgumentException]) | ||
} | ||
) | ||
|
||
} |
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