feat: batch and stream hooks#2087
Conversation
…fields only where needed
…subscription and not going to other client that subscribed the same subscription
…ine subscription closure handling
There was a problem hiding this comment.
I have reviewed all non-test code first because of the size of this PR. I think it makes sense to discuss this first, then tests might have to be adjusted second.
I have a general question regarding the current method of pushing a message batch to brokers. In this approach we abort on first problems, with parts of messages being sent to the broker while others not. Did this change in the way EDFS did it before? Generally I would think batch events should be sent transactionally but I am lacking the historical context here. Just wanted to bring this topic up for discussion.
|
I believe that in the ADR the StreamHookError type is not whats in the code: In ADR In Code File: router/core/subscriptions_modules.go |
…ng-7601-add-streambatcheventhook-and-streampublisheventhook
| requestLog2 := xEnv.Observer().FilterMessage("error applying publish event hooks") | ||
| assert.Len(t, requestLog2.All(), 1) | ||
|
|
||
| require.Len(t, records, 1) |
There was a problem hiding this comment.
Also check the response body here? Like you did on the nats test
…thook-and-streampublisheventhook Resolved in favor of ale/eng-7601-add-streambatcheventhook-and-streampublisheventhook because this branch is based on topic/streams-v1 but changed code afterwards. The reason this is a merge conflict is because on topic/streams-v1 a squashe merge commit let it look like these changes are newer than the ones on this branch.
Summary by CodeRabbit
New Features
Refactor
Bug Fixes
Tests
Chores
How to use the new hook?
The hooks implemented in this PR are StreamBatchEventHook and StreamPublishEventHook.
StreamBatchEventHook is defined here:
cosmo/router/core/subscriptions_modules.go
Line 188 in 3d829f8
StreamPublishEventHook is defined here:
cosmo/router/core/subscriptions_modules.go
Line 201 in 3d829f8
Demo StreamBatchEventHook
Subscription
On the demo graph, we will create a module that filters out messages based on the kafka header
Module code that implement the new hook
Demo StreamPublishEventHook
Mutation
On the demo graph, we will create a module that will add the $employeeId value in a kafka header.
Module code that implement the new hook
Checklist