https://github.com/santik/priceindicator
Exercise with concurrent collections
https://github.com/santik/priceindicator
Last synced: 10 months ago
JSON representation
Exercise with concurrent collections
- Host: GitHub
- URL: https://github.com/santik/priceindicator
- Owner: santik
- Created: 2021-10-15T12:50:36.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2021-10-16T15:18:04.000Z (about 4 years ago)
- Last Synced: 2025-01-14T01:10:04.860Z (12 months ago)
- Language: Java
- Size: 17.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Price publisher/consumer
### Description
2 interfaces were created `PriceConsumer` and `PricePublisher` together with implementations.
I decided to separate interfaces because in this way we can control data flows more flexible.
For example instead of saving prices batch we can create a message for later processing.
Or instead of querying price directly we can request to create a file with all the prices.
#### Implemented data flow is the following:
- When batch run is announced unique batch run id is returned.
- After that price batches can be published with that batch run id.
- Batch run can be finished or canceled any time by the batch run id.
- When batch run is finished or canceled application removes batch run id and price can not be published for this run anymore.
- When batch run is finished the whole batch run data becoming accessible for querying.
- Latest price per id is stored separately for more performant querying.
#### Points for improvement
- Remove not finished batches by timeout.
- Do not process prices synchronously. Instead, we can publish events and process them separately.
### Running
`mvn clean test`