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

FF-3753 feat(dart): Dart SDK #197

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

FF-3753 feat(dart): Dart SDK #197

wants to merge 11 commits into from

Conversation

rasendubi
Copy link
Collaborator

No description provided.

Copied flutter_rust_bridge minimal example[1] and beat it into working:
- vendored simple_build.dart to remove dependency on an unpublished
  git-only package
- updated packages because I couldn't get dart test to work otherwise
- stripped flutter_rust_bridge internal options

[1]: https://github.com/fzyzcjy/flutter_rust_bridge/tree/05247dd90a7fcb2512c5ede13cf00271b0eb548e/frb_example/dart_minimal
Copy link

changeset-bot bot commented Feb 5, 2025

🦋 Changeset detected

Latest commit: 0fd3594

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
eppo_core Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@rasendubi rasendubi marked this pull request as draft February 5, 2025 17:43
@rasendubi rasendubi changed the title feat(dart): Dart SDK FF-3753 feat(dart): Dart SDK Feb 5, 2025
Dropping `BackgroundRuntime` cancels all tracked tasks. This may (and
have) lead to hard to debug issues when configuration poller just
stops working and `.wait_for_configuration()` unhelpfully returns
`PollerThreadPanicked`. (I am a little embarrassed to say how long
this simple issue took me to debug when it was paired with running in
Dart environment.)
@rasendubi rasendubi mentioned this pull request Feb 17, 2025
4 tasks
@rasendubi rasendubi marked this pull request as ready for review February 17, 2025 21:11
@rasendubi
Copy link
Collaborator Author

I'm going to work on adding documentation next but this is now ready for review 🎉

@rasendubi rasendubi requested a review from typotter February 17, 2025 21:12
await this._core!.waitForInitialization();
}

String stringAssignment(String flagKey, Subject subject, String defaultValue) {
Copy link

Choose a reason for hiding this comment

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

Just wanted to note that this is a different signature than usual, with a subject instead of subjectId and subjectAttributes

Copy link
Collaborator Author

@rasendubi rasendubi Feb 19, 2025

Choose a reason for hiding this comment

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

Yeah, the ask for review leaked slightly earlier than I expected, so I didn't have the time to annotate all the interesting parts 🙂

For the difference here: I hate Attributes/ContextAttributes distinction in other SDKs, so I tried to experiment with it. This change makes signature uniform for both assignments and bandits.

Bandit signature for comparison (no ContextAttributes!):

EvaluationResult<String> banditAction(
  String flagKey,
  Subject subject,
  Map<String, Attributes> actions,
  String defaultVariation)

and example usage in Dart (from test):

      final bandit = client.banditAction(
        'banner_bandit_flag',
        Subject('alice')
          ..numberAttribute('age', 25)
          ..stringAttribute('country', 'USA')
          ..stringAttribute('genderIdentity', 'female'),
        {
          'nike': Attributes()
            ..numberAttribute('brand_affinity', 1.0)
            ..stringAttribute('loyalty_tier', 'gold')
            ..boolAttribute('purchased_last_30_days', true),
        },
        'control',
      );

That seems to work better for typed languages that don't allow mixing strings and numbers in the same container. I like it but curious what other think.

@@ -101,6 +101,7 @@ impl BackgroundRuntime {

/// Command background activities to stop and exit.
pub(crate) fn stop(&self) {
log::debug!(target: "eppo", "stopping background runtime");
Copy link

Choose a reason for hiding this comment

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

Did you intend to keep this debug here?

Copy link
Collaborator Author

@rasendubi rasendubi Feb 19, 2025

Choose a reason for hiding this comment

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

Absolutely: 5353290

I've spent a couple of days debugging why poller mysteriously crashes (spoiler: it was just background runtime silently stopping). That log line would cut the debugging to one minute 🙈

@schmit
Copy link

schmit commented Feb 19, 2025

As a first-time Dart user, this looks very clean and insightful! Will be prudent and have a second pair of eyes approve

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