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

refactor(ffi): refactor engine for streaming #430

Merged
merged 55 commits into from
Oct 17, 2024

Conversation

markphelps
Copy link
Contributor

@markphelps markphelps commented Oct 8, 2024

Opening this up for feedback. It hasnt yet been tested with streaming server side changes yet, however I feel like this PR is large enough already that we should go ahead and open it.

What

Refactors the flipt-ffi-engine module with the following major changes:

  • Renames HTTPParser to HTTPFetcher
  • Decouples fetching from the evaluation store
  • Removes generic parameter P from evaluator as it will always use the HTTPFetcher (could prob do the same for Snapshot store in the future
  • Removes unneeded method repace_store to just use replace_snapshot on state change
  • Switches to use Rust channels to communicate state changes, which makes switching to leverage streaming easier as well
  • Adds streaming mode, described below

Polling / Streaming Flow

This adds initial support for flipt-io/flipt#3458

The client will be able to be configured in either streaming or polling mode. Default will be polling, but they will be able to enable streaming via engine options (yet to be decided how this is exposed to user).

Right now this only is a refactor of the existing polling code, as the streaming functionality is never called.

TODO

  • Test
  • Wire up ability to put in streaming mode via engine opts

Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
…ipt-io/flipt-client-sdks into refactor-engine-for-streaming

* 'refactor-engine-for-streaming' of https://github.com/flipt-io/flipt-client-sdks:
  build(deps): bump org.junit:junit-bom in /flipt-client-java (#429)
  build(deps-dev): bump rollup in /flipt-client-browser (#428)
  build(deps-dev): bump rollup in /flipt-client-react (#427)
  build(deps-dev): bump globals in /flipt-client-react (#426)
  build(deps-dev): bump eslint-plugin-react in /flipt-client-react (#425)
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
@codecov-commenter
Copy link

codecov-commenter commented Oct 8, 2024

Codecov Report

Attention: Patch coverage is 58.56481% with 179 lines in your changes missing coverage. Please review.

Project coverage is 84.09%. Comparing base (1f357f8) to head (1d01a26).

Files with missing lines Patch % Lines
flipt-engine-ffi/src/http.rs 61.07% 116 Missing ⚠️
flipt-engine-ffi/src/lib.rs 0.00% 60 Missing ⚠️
flipt-evaluation/src/store.rs 88.23% 2 Missing ⚠️
flipt-evaluation/src/models/source.rs 90.90% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #430      +/-   ##
==========================================
- Coverage   87.42%   84.09%   -3.33%     
==========================================
  Files           9        8       -1     
  Lines        3737     3936     +199     
==========================================
+ Hits         3267     3310      +43     
- Misses        470      626     +156     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
…ipt-io/flipt-client-sdks into refactor-engine-for-streaming

* 'refactor-engine-for-streaming' of https://github.com/flipt-io/flipt-client-sdks:
  feat(browser): allow caller to know if the snapshot was updated (#431)
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
@markphelps markphelps changed the title refactor: refactor engine for streaming refactor(ffi): refactor engine for streaming Oct 14, 2024
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
…ipt-io/flipt-client-sdks into refactor-engine-for-streaming

* 'refactor-engine-for-streaming' of https://github.com/flipt-io/flipt-client-sdks:
  build(deps-dev): bump @eslint/js in /flipt-client-react (#447)
  build(deps-dev): bump @types/react in /flipt-client-react (#445)
  build(deps-dev): bump globals in /flipt-client-react (#443)
  build(deps-dev): bump typescript in /flipt-client-browser (#442)
  build(deps-dev): bump undici in /flipt-client-browser (#441)
  build(deps-dev): bump black in /flipt-client-python (#440)
  build(deps-dev): bump @types/node in /flipt-client-node (#439)
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
@markphelps
Copy link
Contributor Author

@GeorgeMac I think this is ready for a re-review

Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Copy link
Member

@GeorgeMac GeorgeMac left a comment

Choose a reason for hiding this comment

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

Nice one.

Do we want to add comments to all these new Streaming enum types to make it clear this is experimental / cloud only for now?

@markphelps
Copy link
Contributor Author

Nice one.

Do we want to add comments to all these new Streaming enum types to make it clear this is experimental / cloud only for now?

yah will do

) -> Result<(), Error> {
let stream_result = self.fetch_stream().await;

match stream_result {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe it's too late. Could serde_json::StreamDeserializer be used here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe, this works however. do you know if serde_json::StreamDeserializer would provide a benefit?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am worry about bytes and \n on utf-8 string. But it could be done with refactoring.

Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
…ipt-io/flipt-client-sdks into refactor-engine-for-streaming

* 'refactor-engine-for-streaming' of https://github.com/flipt-io/flipt-client-sdks:
  feat: expose if refresh changed state in node sdk (#450)
@markphelps
Copy link
Contributor Author

Im going to add more tests coverage and document the new streaming option before merging

Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
@kodiakhq kodiakhq bot merged commit 40022f7 into main Oct 17, 2024
18 checks passed
@kodiakhq kodiakhq bot deleted the refactor-engine-for-streaming branch October 17, 2024 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants