-
Notifications
You must be signed in to change notification settings - Fork 5
Introduce RS3ConfigSetter #455
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
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
74 changes: 74 additions & 0 deletions
74
kafka-client/src/main/java/dev/responsive/kafka/api/config/RS3ConfigSetter.java
This file contains hidden or 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,74 @@ | ||
| /* | ||
| * | ||
| * Copyright 2025 Responsive Computing, Inc. | ||
| * | ||
| * This source code is licensed under the Responsive Business Source License Agreement v1.0 | ||
| * available at: | ||
| * | ||
| * https://www.responsive.dev/legal/responsive-bsl-10 | ||
| * | ||
| * This software requires a valid Commercial License Key for production use. Trial and commercial | ||
| * licenses can be obtained at https://www.responsive.dev | ||
| */ | ||
|
|
||
| package dev.responsive.kafka.api.config; | ||
|
|
||
| import dev.responsive.kafka.internal.stores.SchemaTypes.KVSchema; | ||
| import dev.responsive.kafka.internal.stores.SchemaTypes.SessionSchema; | ||
| import dev.responsive.kafka.internal.stores.SchemaTypes.WindowSchema; | ||
| import java.util.Map; | ||
| import java.util.Optional; | ||
| import org.apache.kafka.common.Configurable; | ||
|
|
||
| public interface RS3ConfigSetter extends Configurable { | ||
|
|
||
| /** | ||
| * Sets the configs for a {@link org.apache.kafka.streams.state.KeyValueStore} | ||
| * with the provided name and schema. Can return {@link Optional#empty()} to defer to | ||
| * the default settings for the given store type. | ||
| * | ||
| * @return the configs to override for this store | ||
| */ | ||
| RS3StoreParams keyValueStoreConfig(String storeName, KVSchema schema); | ||
|
|
||
| /** | ||
| * Sets the configs for a {@link org.apache.kafka.streams.state.WindowStore} | ||
| * with the provided name and schema. Can return {@link Optional#empty()} to defer to | ||
| * the default settings for the given store type. | ||
| * | ||
| * @return the configs to override for this store | ||
| */ | ||
| RS3StoreParams windowStoreConfig(String storeName, WindowSchema schema); | ||
|
|
||
| /** | ||
| * Sets the configs for a {@link org.apache.kafka.streams.state.SessionStore} | ||
| * with the provided name and schema. Can return {@code super.sessionStoreConfig} to defer to | ||
| * the default settings for the given store type. | ||
| * | ||
| * @return the configs to override for this store | ||
| */ | ||
| RS3StoreParams sessionStoreConfig(String storeName, SessionSchema schema); | ||
|
|
||
| @Override | ||
| default void configure(final Map<String, ?> configs) { | ||
| } | ||
|
|
||
| class DefaultRS3ConfigSetter implements RS3ConfigSetter { | ||
|
|
||
| @Override | ||
| public RS3StoreParams keyValueStoreConfig(final String storeName, final KVSchema schema) { | ||
| return RS3StoreParams.defaultKV(schema); | ||
| } | ||
|
|
||
| @Override | ||
| public RS3StoreParams windowStoreConfig(final String storeName, final WindowSchema schema) { | ||
| return RS3StoreParams.defaultWindow(schema); | ||
| } | ||
|
|
||
| @Override | ||
| public RS3StoreParams sessionStoreConfig(final String storeName, final SessionSchema schema) { | ||
| return RS3StoreParams.defaultSession(schema); | ||
| } | ||
|
|
||
| } | ||
| } | ||
53 changes: 53 additions & 0 deletions
53
kafka-client/src/main/java/dev/responsive/kafka/api/config/RS3StoreParams.java
This file contains hidden or 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,53 @@ | ||
| /* | ||
| * | ||
| * Copyright 2025 Responsive Computing, Inc. | ||
| * | ||
| * This source code is licensed under the Responsive Business Source License Agreement v1.0 | ||
| * available at: | ||
| * | ||
| * https://www.responsive.dev/legal/responsive-bsl-10 | ||
| * | ||
| * This software requires a valid Commercial License Key for production use. Trial and commercial | ||
| * licenses can be obtained at https://www.responsive.dev | ||
| */ | ||
|
|
||
| package dev.responsive.kafka.api.config; | ||
|
|
||
| import dev.responsive.kafka.internal.stores.SchemaTypes.KVSchema; | ||
| import dev.responsive.kafka.internal.stores.SchemaTypes.SessionSchema; | ||
| import dev.responsive.kafka.internal.stores.SchemaTypes.WindowSchema; | ||
| import java.util.Optional; | ||
|
|
||
| public class RS3StoreParams { | ||
|
|
||
| public static final Optional<Integer> DEFAULT_FACT_STORE_FILTER_BITS = Optional.of(20); | ||
|
|
||
| private final Optional<Integer> filterBitsPerKey; | ||
|
|
||
| private RS3StoreParams(final Optional<Integer> filterBitsPerKey) { | ||
| this.filterBitsPerKey = filterBitsPerKey; | ||
| } | ||
|
|
||
| public static RS3StoreParams defaultKV(final KVSchema schema) { | ||
| final Optional<Integer> defaultFilterBitsPerKey = schema == KVSchema.FACT | ||
| ? DEFAULT_FACT_STORE_FILTER_BITS | ||
| : Optional.empty(); | ||
| return new RS3StoreParams(defaultFilterBitsPerKey); | ||
| } | ||
|
|
||
| public static RS3StoreParams defaultWindow(final WindowSchema schema) { | ||
| return new RS3StoreParams(Optional.empty()); | ||
| } | ||
|
|
||
| public static RS3StoreParams defaultSession(final SessionSchema schema) { | ||
| return new RS3StoreParams(Optional.empty()); | ||
| } | ||
|
|
||
| public RS3StoreParams withFilterBitsPerKey(final int filterBitsPerKey) { | ||
| return new RS3StoreParams(Optional.of(filterBitsPerKey)); | ||
| } | ||
|
|
||
| public Optional<Integer> filterBitsPerKey() { | ||
| return filterBitsPerKey; | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
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.
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.
Perhaps we could return a more specific type (e.g.
RS3WindowStoreParams) in case there are different configurations for the respective store?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, that's probably the right thing to do...I considered that but ended up consolidating them to reduce API surface. But the problem with a generic RS3StoreParams is that it's up to the user to use the correct base/default configs for the given store type. Which will only become worse if we do have different configs for different store types in the furure
i'll go back to the store-specific params