Skip to content

DatastoreRepository

Bogdan Ciobanu edited this page Sep 9, 2020 · 4 revisions

DatastoreRepository is the implementation of the DataRepository interface

Purpose

The purpose of this class is to serve as a translator between the Google Cloud Datastore - Spring Cloud GCP APIs, and the Fetcher and REST API components of this project. The functionality is described by the DataRepository interface, but this implementation is focused on the Google Cloud Datastore database implementation.

Data Model

All "revision" type entries are modeled after the BuildInfo class, for which the primary key "id" is the commit hash, and all other fields are properties of the resulting entity. Spring Cloud GCP API provides a seamless way of storing an @Entity annotated POJO into the Google Cloud Datastore.

Implementation

The implementation of this class relies heavily upon the Spring Cloud GCP Framework, since it greatly simplifies handling the nested structure of the BuildInfo class. The Spring Cloud GCP API is interleaved with the Google Cloud Datastore, since getLastRevisionEntries requires more complicated queries, which aren't provided by the Spring Cloud GCP API. The create/update/get/delete methods work by delegating the save/save/findById/delete methods from the Spring Cloud GCP, while getLastRevisionEntries has to create a query for all "revision" entries, sort descendingly by timestamp, and limit the results starting from an offset.

Cleanup

GCP provides in-depth data retention policy options, as such, this component does not have the responsibility of regular cleanup of old entries. However, if this is desired, it could be achieved by querying all entries older than a given timestamp, and deleting them sequentially, or in bulk, using a Scheduled annotated routine.


Relevant Links: