Make cloud interfaces and abstract classes less GCP specific
Hello!
During implementing Anthos
provider we faced troubles with creating the concrete Journal
class: here.
If we understand correctly, AbstractJournal
and AbstractJournalTransaction
classes simply reproduce GCP Datastore interfaces. It is ok for GCP implementation, because there is no extra effort needed for implementing concrete journal classes. However, it is hard to implement concrete journal classes for other CSPs. This becomes obvious when we compare the number of lines for GCP and other CSPs particular journal classes (e.g., GCP and Azure).
Also, using Datastore "low-level" logic in the core code makes this code hard to read and debug. E.g., for Anthos we use PostgreSQL database and the concrete implementation required a lot of workarounds to fit Datastore "low-level" methods into SQL. For example, there are specific Datastore operators in the abstract class (here).
I'd suggest refactoring the common code and switch from using Datastore methods to focusing on more general and high-level logic.
For example, instead of using this in the common code
let query = journalClient.createQuery(
Config.SEISMIC_STORE_NS + '-' + dataset.tenant + '-' + dataset.subproject, Config.DATASETS_KIND);
query = query.filter('name', dataset.name).filter('path', dataset.path);
const [entities] = await journalClient.runQuery(query);
We could use something like this:
// Just an example
const entity = await journalClient.getEntity(dataset.path, dataset.name);
In this case, we could be more concise and cleaner in concrete CSP implementations. Also, implementing high-level classes lets us use the best practices for each particular data base.