Skip to content

[DO NOT MERGE] Support configurable PushFailurePolicy on MutableStore (#678) - #769

Open
binayshaw7777 wants to merge 2 commits into
MobileNativeFoundation:mainfrom
binayshaw7777:binay/feat-push-failure-policy
Open

binayshaw7777 wants to merge 2 commits into
MobileNativeFoundation:mainfrom
binayshaw7777:binay/feat-push-failure-policy

Conversation

@binayshaw7777

Copy link
Copy Markdown

Closes #678

Description

In RealMutableStore, when eager conflict resolution during a stream request fails, the error was logged and delegate.stream(request) was invoked unconditionally (marked with // TODO(#678)). This could trigger a remote fetch that overwrites unpushed dirty local data in the Source of Truth.

This PR introduces PushFailurePolicy:

  • FAIL_FAST: Emits StoreReadResponse.Error and halts without fetching.
  • SKIP_FETCH_KEEP_LOCAL: Suppresses remote fetch and serves only local data, preserving unpushed modifications.
  • IGNORE_AND_FETCH: Preserves legacy behavior (default).

Configurable via MutableStoreBuilder.pushFailurePolicy(policy) and Store.asMutableStore(..., pushFailurePolicy = ...).

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Test Plan

  • Added stream_givenConflictResolutionFailsAndFailFast_whenReading_thenEmitsErrorAndAborts in RealMutableStoreTest.kt.
  • Added stream_givenConflictResolutionFailsAndSkipFetchKeepLocal_whenReading_thenEmitsLocalOnly in RealMutableStoreTest.kt.
  • Verified all unit tests pass with ./gradlew :store:jvmTest.

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my change is effective
  • New and existing unit tests pass locally with my changes

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🆕 Triage

Development

Successfully merging this pull request may close these issues.

[Feature Request] Enable Configuration of Conflict Resolution Strategies

1 participant