Skip to content

feat: Add generic entity synchronizer and add SyncWebFeatures#1692

Merged
jcscottiii merged 3 commits intomainfrom
jcscottiii/add-web-feature-sync-method
Aug 6, 2025
Merged

feat: Add generic entity synchronizer and add SyncWebFeatures#1692
jcscottiii merged 3 commits intomainfrom
jcscottiii/add-web-feature-sync-method

Conversation

@jcscottiii
Copy link
Collaborator

This commit introduces a generic entitySynchronizer component to reconcile the state of a Spanner table with a desired list of entities. This new component handles inserts, updates, and deletes in a single, auditable operation.

To support this, the generic entity mapper interfaces have been refactored from bigger definitions into smaller, single-responsibility interfaces (e.g., readOneMapper, mergeMapper, deleteByStructMapper) that are composed for specific components. This improves the design by ensuring components only depend on the capabilities they require.

Key changes include:

  • A new entitySynchronizer that can perform a full sync on any table.
  • A syncableEntityMapper interface composed of the new building blocks.
  • SyncWebFeatures is the first implementation, providing a robust way to manage the WebFeatures table.
  • The GetKey method has been renamed to the more explicit GetKeyFromExternal across all existing mappers for clarity and consistency.

In a future commit, the web feature data consumer will be updated to use SyncWebFeatures. The existing UpsertWebFeature method will then be deprecated and removed in a future change.

This commit introduces a generic `entitySynchronizer` component to reconcile the state of a Spanner table with a desired list of entities. This new component handles inserts, updates, and deletes in a single, auditable operation.

To support this, the generic entity mapper interfaces have been refactored from bigger definitions into smaller, single-responsibility interfaces (e.g., `readOneMapper`, `mergeMapper`, `deleteByStructMapper`) that are composed for specific components. This improves the design by ensuring components only depend on the capabilities they require.

Key changes include:
- A new `entitySynchronizer` that can perform a full sync on any table.
- A `syncableEntityMapper` interface composed of the new building blocks.
- `SyncWebFeatures` is the first implementation, providing a robust way to manage the `WebFeatures` table.
- The `GetKey` method has been renamed to the more explicit `GetKeyFromExternal` across all existing mappers for clarity and consistency.

In a future commit, the web feature data [consumer](https://github.com/GoogleChrome/webstatus.dev/tree/main/workflows/steps/services/web_feature_consumer) will be updated to use `SyncWebFeatures`. The existing `UpsertWebFeature` method will then be deprecated and removed in a future change.
@jcscottiii jcscottiii requested a review from jrobbins August 5, 2025 22:00
@jcscottiii jcscottiii added this pull request to the merge queue Aug 6, 2025
Merged via the queue into main with commit 2696629 Aug 6, 2025
7 checks passed
@jcscottiii jcscottiii deleted the jcscottiii/add-web-feature-sync-method branch August 6, 2025 14:46
jcscottiii added a commit that referenced this pull request Aug 6, 2025
…te features

Fixes #321

This uses the work from #1692 to sync the state of web features in the web features consumer.

Instead of only upserting web features, this will allow us to delete features that no longer exist from the database.
github-merge-queue bot pushed a commit that referenced this pull request Aug 6, 2025
…te features (#1695)

Fixes #321

This uses the work from #1692 to sync the state of web features in the web features consumer.

Instead of only upserting web features, this will allow us to delete features that no longer exist from the database.
@jstenback jstenback mentioned this pull request Aug 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants