Skip to content

Conversation

typotter
Copy link
Collaborator

@typotter typotter commented Apr 24, 2025

Eppo Internal:

🎟️ Fixes FF-4351

Motivation and Context

In order to support Android API level 21, we need to remove some of the more modern features previously integrated. One such construct is the CompletableFuture, java's version of the Promise. In order to be compatible all the way back to java6, we need to replace these async structures with Callbacks for better or worse (and we can't even use lambdas)

Description

  • Change the CallbackManager class to use a dispatcher that gets around using different callback structures with a callback manager (needed only because we can't use lambdas)
  • remove all CompletableFutures, plumb callbacks everywhere for async
  • Extracted interface for HttpClient
  • new MockHttpClient classes for greatly simplifying tests.

Breaking Changes

  • Initial Config can no longer be a future.
  • Signature changed: protected void loadConfigurationAsync(EppoActionCallback<Configuration> callback)
  • Signature changed: public void saveConfiguration(@NotNull final Configuration configuration)
  • renamed apiKey to sdkKey
  • removed deprecated expectObfuscated parameter
  • removed deprecated host parameter
  • removed deprecated Configuration.Builder method

New API

  • New method: activateConfiguration

How has this been documented?

  • Update docs as needed in downstream SDKs

How has this been tested?

  • Integrate in downstream SDKs and test

@typotter typotter marked this pull request as ready for review April 25, 2025 05:15
@typotter typotter requested a review from aarsilv April 25, 2025 05:15
Copy link
Contributor

@aarsilv aarsilv left a comment

Choose a reason for hiding this comment

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

Way to puzzle through this! 💪 💪 💪

I imagine for the upstream clients we could still present the completable future interface if desired by wrapping the callbacks. Also Lambdas may be ok with "desugaring".

private final CallbackManager<Configuration, Configuration.ConfigurationCallback>
configChangeManager =
new CallbackManager<>(
// no lambdas before java8
Copy link
Contributor

Choose a reason for hiding this comment

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

Are they android 21 compatible through its "desugaring"? Would that be ok to support or, do we need stay away from that entirely?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The handy thing is that for the dev, if they're using a platform that supports lambdas, they can use a lambda when they register a callback (this is in EppoClient). Since the callback interface there is a once function interface, Java will treat it interchangeably with a lambda whose signature matches the function.

@aarsilv aarsilv assigned typotter and unassigned aarsilv Apr 25, 2025
Simplified callback interface
Renamed methods to match "gen2" sdk naming
Added activateConfiguration method
expose isGracefulMode to subclasses
moved graceful mode check top-level callsites (in poller and in assignment calls)
renamed callbacks
clarified init in tests
@typotter typotter changed the title chore: Replace use of CompletableFuture with callbacks chore: v4 - android21 compatible mega PR May 21, 2025
typotter and others added 3 commits May 21, 2025 14:56
* chore: replace use of string.join for android 21 (#111)
* extract base64 codec for portation
* chore: refactor out JSON parsing
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