Skip to content

When can I use a Reducer? What does it emit? #51

Answered by HQarroum
spagdoon0411 asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @spagdoon0411!

That's a good question. The TLDR; is that the reducer aggregates the CloudEvents passed by upstream middlewares and combines them into a JSON document (a JSON array, in fact) that contains the aggregated cloudevents. It does that aggregation based on the given reducer strategy (TimeWindowStrategy, StaticCounterStrategy, ConditionalStrategy). The output of a reducer is always application/cloudevents+json. So the output of a reducer would like like this :

[{
  "specversion": "1.0",
  "id": "1780d5de-fd6f-4530-98d7-82ebee85ea39",
  "type": "document-created",
  ...
}, {
  // Another cloudevent
}]

Now regarding your question of when a reducer can be used prior to another m…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@spagdoon0411
Comment options

Answer selected by spagdoon0411
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants