Skip to content

feat!: Require feature stores to report whether an upsert or delete applied - #482

Draft
keelerm84 wants to merge 4 commits into
feat/9.xfrom
mk/SDK-81/store-write-result
Draft

keelerm84 wants to merge 4 commits into
feat/9.xfrom
mk/SDK-81/store-write-result

Conversation

@keelerm84

Copy link
Copy Markdown
Member

FeatureStore#upsert and FeatureStore#delete must now return true when the
store applies the write, and false when the store already has an item with
the same or a higher version. FeatureStoreCore#upsert_internal, used with
CachingStoreWrapper, must return the same boolean instead of the final item.

Before this change, the SDK sent flag change events after every upsert or
delete from the data source, even when the store rejected a stale write. A
repeated or out-of-order update therefore produced change events for flags
that did not change. The SDK now updates its dependency tracking and sends
change events only when the store reports that it applied the write.

When a core reports that it did not apply an upsert, CachingStoreWrapper
reads the current item from the core and caches it. This matches the Go
SDK's persistent store wrapper.

Custom store implementers:

  • A FeatureStore that returns nil or another falsy value from upsert or
    delete stops flag change events for those writes. The default methods in
    LaunchDarkly::Interfaces::FeatureStore return nil, so implementations
    must return the result explicitly.
  • A FeatureStoreCore must return true or false from upsert_internal. The
    wrapper no longer accepts the final item as the return value.

The SDK no longer checks with respond_to? for the optional feature store
methods. Custom stores must now implement them.

A custom LaunchDarkly::Interfaces::FeatureStore must implement:

- monitoring_enabled? -- return true only if the store publishes status
  updates when it becomes unavailable and when it recovers. In-memory
  stores return false.
- available? -- return true if the underlying data store is reachable.
  The SDK polls this method after a store operation fails, while
  monitoring is enabled. Stores that cannot become unavailable return
  true.
- stop -- release resources. The SDK calls it when the client closes.

A custom FeatureStoreCore used with CachingStoreWrapper must implement
available? and stop. CachingStoreWrapper now always reports
monitoring_enabled? as true and delegates available? to the core.

Before this change, a store without these methods silently lost status
monitoring, and a core without available? turned monitoring off. The
interface docs also disagreed on whether available? would stay. Making
the methods required gives one clear contract and removes the probing.

The lifecycle method stays named stop. All built-in stores, the big
segment store, data sources and event processors already use stop, so
renaming only the feature store to close would make the SDK less
consistent.
…pplied

FeatureStore#upsert and FeatureStore#delete must now return true when the
store applies the write, and false when the store already has an item with
the same or a higher version. FeatureStoreCore#upsert_internal, used with
CachingStoreWrapper, must return the same boolean instead of the final item.

Before this change, the SDK sent flag change events after every upsert or
delete from the data source, even when the store rejected a stale write. A
repeated or out-of-order update therefore produced change events for flags
that did not change. The SDK now updates its dependency tracking and sends
change events only when the store reports that it applied the write.

When a core reports that it did not apply an upsert, CachingStoreWrapper
reads the current item from the core and caches it. This matches the Go
SDK's persistent store wrapper.

Custom store implementers:

- A FeatureStore that returns nil or another falsy value from upsert or
  delete stops flag change events for those writes. The default methods in
  LaunchDarkly::Interfaces::FeatureStore return nil, so implementations
  must return the result explicitly.
- A FeatureStoreCore must return true or false from upsert_internal. The
  wrapper no longer accepts the final item as the return value.

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

None yet

Development

Successfully merging this pull request may close these issues.

1 participant