Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Storage API and implementation more friendly to Spine's storage-specific libraries #1533

Merged
merged 59 commits into from
Nov 9, 2023

Conversation

armiol
Copy link
Contributor

@armiol armiol commented Sep 2, 2023

This PR addresses some inconsistencies in both Storage API and its base/abstract implementation, so that descendant port libraries, such as Spine RDBMS could migrate their features to Spine 2.x with less hassle.

Major breaking change (breaking for SPI users, that is) is merging EntityRecordSpec and MessageRecordSpec into a single RecordSpec type. It has been done for several reasons.

  • Allow to assemble the columns for EntityRecords consistently on top of EntityRecord itself. Previously, the column values in EntityRecordWithColumns — which were picked from Entity state directly — could differ from those values actually stored in EntityRecord.
  • Provide an ability to re-assemble RecordWithColumns instances purely with the relevant Message instance along with its spec. Previously, Entity-related RecordWithColumns could only be assembled with an Entity instance.
  • Simplify the code in Storage API, eliminating one of type inheritance branches.

Other changes include:

  • Storage column definitions made public.
  • Transformation of generic entity queries into Storage-internal RecordQuery instances now preserves the type of the column, by which values query aims to filter the dataset.
  • Behaviour of AggregateStorage.historyBackward() has been made eager instead of lazy, as previously. This is needed to ensure the access to the history under the circumstances of maintaining the connection to the database.
  • More documentation was added to the tenancy modes recommended for certain scenarios, such as configuring system storages (e.g. InboxStorage).
  • FieldMaskApplier has been made @Internal-ly public, as its functionality is required in descendant libraries to prevent any code duplication.

@armiol armiol self-assigned this Sep 2, 2023
@armiol
Copy link
Contributor Author

armiol commented Sep 2, 2023

@alexander-yevsyukov PTAL.

@codecov
Copy link

codecov bot commented Sep 2, 2023

Codecov Report

Merging #1533 (e4ca6ea) into master (349fc83) will decrease coverage by 0.08%.
The diff coverage is 96.98%.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1533      +/-   ##
============================================
- Coverage     89.90%   89.83%   -0.08%     
+ Complexity     5057     5025      -32     
============================================
  Files           648      645       -3     
  Lines         15806    15751      -55     
  Branches        925      920       -5     
============================================
- Hits          14211    14150      -61     
- Misses         1269     1274       +5     
- Partials        326      327       +1     

Copy link
Contributor

@alexander-yevsyukov alexander-yevsyukov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@armiol armiol changed the title Expose the definitions of Storage columns Expose and adjust Storage API and implementation for storage-specific libraries Sep 30, 2023
@armiol armiol changed the title Expose and adjust Storage API and implementation for storage-specific libraries Modify Storage API and implementation for storage-specific libraries Sep 30, 2023
@armiol armiol changed the title Modify Storage API and implementation for storage-specific libraries Make Storage API and implementation more friendly to Spine's storage-specific libraries Sep 30, 2023
@armiol
Copy link
Contributor Author

armiol commented Nov 8, 2023

@alexander-yevsyukov it has been a long time since this PR was first approved. Many things have changed since then. PTAL again.

Copy link
Contributor

@alexander-yevsyukov alexander-yevsyukov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider my comments regarding @SPI annotations.

* @param <S>
* type of entity state
*/
private static final class MemoizingUnpacker<I, S extends EntityState<I>> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this class to the bottom of the outer one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

*/
@SPI
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming that the whole package is annotated as @SPI, the classes and interfaces that were annotated directly should lose the redundant annotation too. E.g. ColumnMapping, and ColumnTypeMagging are currently annotated directly.

Please have a look.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, consider removing the package-wide annotation and use only annotation on classes and interfaces.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have removed @SPI from package members in favour of package-level annotation.

@@ -89,8 +89,5 @@ message MirrorId {
// Entity columns of the associated aggregate.
message EntityColumns {

// TODO:2018-09-06:dmytro.dashenkov: Support entity columns.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@armiol
Copy link
Contributor Author

armiol commented Nov 9, 2023

@alexander-yevsyukov while reviewing the ... .storage package, I have also addressed some minor documentation issues, killed some unused methods, and commented on warnings.

And considering @SPI-ness, I have added an explicit test for RecordWithColumns API.

@armiol
Copy link
Contributor Author

armiol commented Nov 9, 2023

@alexander-yevsyukov PTAL.

Copy link
Contributor

@alexander-yevsyukov alexander-yevsyukov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@armiol armiol merged commit e00ad8f into master Nov 9, 2023
7 checks passed
@armiol armiol deleted the expose-storage-column-defs branch November 9, 2023 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants