Open shaun-forgie opened 1 month ago
Is it ok while consume usage record we also do the validation that
It is more efficient to parse catalogs and cache usage unit types for a given tenant and then to process all usage messages in their queue. You would not want to do the parsing and caching of these units every time you processed a single message. The obvious optimisation would be pulling and processing short batches of messages in progressive cycles.
Since in a queue multiple tenants can push message. So while pulling and processing a short batches of message. In batch itself can have messages of different tenant. And each tenant have different catalog so for each individual message we have to do getCatalog() to extract catalog units.
Reading a tenant catalog to parse the usage unit type values on every message will be an expensive operation. You may want to cache these values in a map with TTL value to optimise this validation step.
I have moved the code base to our cashfree org open source github account and there I have added this validation in the PR itself - Pull Request #1. Please use CashfreeOSS as the new repo
It should not be possible to load tenant usage records into Kill Bill for usage unit types that are not defined in current or previous tenant catalogs.
This usage message validation will need to be tenant specific and aware of catalog values.