Writing Your First Aggregator
Since this is the first Aggregator, here is the basic shape of one:
| function createHandlers ({ queries }) { |
| return { |
| } |
| } |
| |
| |
| function createQueries ({ db }) { |
| return { |
| } |
| } |
| |
| function build ({ db, messageStore }) { |
| const queries = createQueries({ db }) |
| const handlers = createHandlers({ queries }) |
| return { |
| queries, |
| handlers, |
| } |
| } |
| |
| module.exports = build |
Our Aggregators handle messages, so they have handlers. They also interact with a database, so they have queries. There is a top-level function, which we name build that receives dependencies, namely db and messageStore, references to the database and the Message Store, respectively. ...
Get Practical Microservices now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.