This service allows you to update the Single View when a new projection changes occurs.
It requires MongoDB and Kafka to be installed in your platform. The former is used to read the projections changes and update the Single View, the latest is used to notify the events happening, like a Single View creation.
If you want to write your own code for your Single View Creator service we suggest you to start from our Single View Creator Template which contains several utilities that can help you.
- TYPE: Identifies the type of projection changes that need to be read. It should be set equals to the Single View name you want to update.
- SCHEDULING_TIME: an amount of time in milliseconds, every X milliseconds the service wake up and check if there are some projectionschanges in
NEWstate to work on. The service continue working until no more new projections changes are found, if so he goes to sleep for X milliseconds."
- PROJECTIONS_CHANGES_COLLECTION: If not customized from Advanced: fd-pc-SYSTEM_ID where SYSTEM_ID is the name of the System of Records this Single View Creator is responsible for.
- SINGLE_VIEWS_COLLECTION: the name of the Single View which this service is responsible for
- SINGLE_VIEWS_ERRORS_COLLECTION: a MongoDB collection where you want to save the errors the occurs
- SINGLE_VIEWS_PORTFOLIO_ORIGIN: Identifies the System ID of the System of Records which this Single View Creator is responsible for.
- KAFKA_SVC_EVENTS_TOPIC: topic where to send the events that happens to the single view
- KAFKA_BA_TOPIC: topic where to send the 'before-after' (data before and after the changes)
- SEND_BA_TO_KAFKA: true if you want to send to Kafka the 'before-after' information about the update changes of the single view
The Single View creator need a Configuration, named as you prefer, mounted on the path
/home/node/app/src with the following files:
It takes in input the identifier of the projection change and return the key object used to select the document of the Single View collection that need to be updated.
In the example below, we expect to have the field
myId as primary key of the Single View collection.
It takes as input a MongoDB instance and returns a function. This function takes as input the projection change identifier and returns an array. If it's empty, than it will be executed a delete on the single view identified by the singleViewKeyGenerator result. If it's not empty, than it will be executed an upsert on the single view identified by the singleViewKeyGenerator result.
Note: If the pipeline returns an array with more than one element, only the first element will be used for the upsert.
It's a function that takes as argument the first element (if defined) of the result of the pipeline, and returns an object containing the value updated for the single view. The object returned should match the schema of the single view.