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

feat(ruby): add offline initialization and Configuration API #39

Merged
merged 2 commits into from
Oct 11, 2024

Conversation

rasendubi
Copy link
Collaborator

This PR adds the ability to initialize Ruby SDK in offline mode by passing poll_interval_seconds: nil and getting/setting configuration by using configuration/configuration= methods on EppoClient.

@rasendubi rasendubi requested a review from aarsilv October 2, 2024 16:42
@rasendubi rasendubi force-pushed the feat-ruby-offline-init branch from 337d1b4 to 707bc82 Compare October 2, 2024 16:45
Base automatically changed from perf-minimize-copying to main October 8, 2024 14:18
@rasendubi rasendubi force-pushed the feat-ruby-offline-init branch from 454df8b to 4e93251 Compare October 8, 2024 14:21
@rasendubi rasendubi force-pushed the feat-ruby-offline-init branch from 4e93251 to 3797d11 Compare October 8, 2024 16:01
Copy link

@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.

Thanks for doing this! Would love some explicit testing now hat happens if they give it a garbage initial config, but otherwise it's looking great 🚀


# require 'eppo_client'

RSpec.describe EppoClient::Configuration do
Copy link

Choose a reason for hiding this comment

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

🙌

end
end

describe "bandits_configuration()" do
Copy link

Choose a reason for hiding this comment

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

🔥

end
end

it "can be reinstantiated from own configuration" do
Copy link

Choose a reason for hiding this comment

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

💪

Comment on lines +71 to +72
expect(config1.flags_configuration).to eq(config2.flags_configuration)
expect(config1.bandits_configuration).to eq(config2.bandits_configuration)
Copy link

Choose a reason for hiding this comment

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

🔥

# guarantee. We're using it here because serialization order of
# bandits is not guaranteed.
expect(JSON.parse(config1.bandits_configuration)).to eq(JSON.parse(config2.bandits_configuration))
end
Copy link

Choose a reason for hiding this comment

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

I wonder if we should test what happens if it's initialized with an invalid JSON configuration (e.g., an empty file). I'm thinking we want the SDK to boot but with no pre-initialized flags, perhaps logging a warning?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There's a test for that. It will fail to create a Configuration.

Copy link
Member

@leoromanovsky leoromanovsky left a comment

Choose a reason for hiding this comment

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

Sorry for missing this

@rasendubi rasendubi merged commit 427fed8 into main Oct 11, 2024
24 checks passed
@rasendubi rasendubi deleted the feat-ruby-offline-init branch October 11, 2024 16:11
}.to raise_error TypeError
end

it "throws on parse error" do
Copy link

Choose a reason for hiding this comment

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

🙌

Sorry I missed this 🤦

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.

3 participants