-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add BatchingProcessor #1
Conversation
int capacity; | ||
long maxRetryCount; | ||
|
||
private final ConcurrentMap<String, BufferedTaskGroup> windowedTasks = new ConcurrentHashMap<>(64, 0.75f, |
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.
capacityやload factorなどを詳細に設定する理由ってなんでしょうか?
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.
すみません、参考元をそのままコピペしてしまっただけで特に理由はないですmm
@Override | ||
public void process(ProcessingContext<T> context, T task) throws InterruptedException { | ||
String key = context.key(); | ||
BufferedTaskGroup taskGroup = windowedTasks.get(key); |
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.
見たところkeyごとにbatchingする設計のようですが、key単位でのバッチングは以下のようなデメリットがあるかと思います。
- keyのcardinalityが高い時に、バッチングが効かずにほとんどlingerでのflushとなる
key単位でのバッチングが有効なケースもあるとは思いますが、Decatonでbuilt-inで提供することを考えると、シンプルにBatchingProcessor instance単位でのバッチングが行われる、というほうがより分かりやすいし多くのユースケースにマッチするのではないでしょうか。
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.
instance 単位でバッチングが行えるように書き換えました。(大部分の変更になってしまいレビュー負担をおかけしてすみません)
} | ||
|
||
BatchingProcessor( | ||
BiConsumer<String, List<BufferedTask<T>>> processor, |
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.
実際のprocessingロジックをBiConsumerで受け取るのではなく、BatchingProcessorをabstract classにしてuserに実装してもらうほうが、processorのlifecycle管理をDecatonに移譲できてよいと思いました。
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.
承知しました!
https://github.com/line/decaton 側に draft PR を直接たてるため、この PR はクローズします |
進捗確認用 PR