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: delta api implementation #626

Merged
merged 24 commits into from
Jan 10, 2025
Merged

feat: delta api implementation #626

merged 24 commits into from
Jan 10, 2025

Conversation

sjaanus
Copy link
Collaborator

@sjaanus sjaanus commented Jan 8, 2025

Now edge can understand and talk to Unleash Delta API. There is cli flag delta to enable this feature.

Copy link

github-actions bot commented Jan 8, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Files

@sjaanus sjaanus changed the title feat: delta api implementation ]feat: delta api implementation Jan 8, 2025
@sjaanus sjaanus changed the title ]feat: delta api implementation [WIP]feat: delta api implementation Jan 8, 2025
@sjaanus sjaanus changed the title [WIP]feat: delta api implementation feat: delta api implementation Jan 9, 2025

#[actix_web::test]
#[tracing_test::traced_test]
async fn test_delta() {
Copy link
Collaborator Author

@sjaanus sjaanus Jan 9, 2025

Choose a reason for hiding this comment

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

Testing whether, after the ETag is provided by Edge, Edge can successfully apply the delta when Unleash sends a new delta.

Copy link
Member

@sighphyre sighphyre left a comment

Choose a reason for hiding this comment

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

This is looking cool!

Can I please suggest we put this behind a compiler flag while we test this? As soon as we release publicly, this becomes a huge pain to rollback or change things if we need

server/src/cli.rs Outdated Show resolved Hide resolved
server/src/feature_cache.rs Outdated Show resolved Hide resolved
server/src/http/feature_refresher.rs Outdated Show resolved Hide resolved
@@ -0,0 +1,159 @@
mod delta_test {
Copy link
Member

Choose a reason for hiding this comment

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

This is a weird place to put tests in my opinion. Are these very long running or a pain to setup for some reason? Can they not just put alongside the code that they're testing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Feature refresher is already so big, 1700 lines. It is super hard to follow as a newcomer.

Copy link
Member

Choose a reason for hiding this comment

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

I think that's a signal that feature refresher is too big and new code needs to be split out, rather than moving tests out

Copy link
Member

@chriswk chriswk Jan 9, 2025

Choose a reason for hiding this comment

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

Probably add a new delta_refresher module, which can still extend FeatureRefresher with methods by using

impl FeatureRefresher {
  /// The delta code
}

#[cfg(test)]
mod tests {
 /// our delta tests, that way we won't have to compile a separate module either.
}

That also means we can readd the #[cfg(test)] to the new method for unleash client.

Copy link
Member

Choose a reason for hiding this comment

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

Doing it that way, also allows doing what Simon suggests and add a delta compiler flag
basically, in the http module, you'd declare

#[cfg(feature = "delta")]
mod delta_refresher;

Copy link
Member

Choose a reason for hiding this comment

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

But also a good observation on the size (I'm assuming the 1700 lines includes the test part of the code as well).

It might point towards feature_refresher needing to be a folder with multiple files rather than one file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added it behind compiler flag.

@sjaanus sjaanus requested a review from sighphyre January 9, 2025 13:07
Copy link
Member

@sighphyre sighphyre left a comment

Choose a reason for hiding this comment

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

Very nice. LGTM

@@ -217,6 +217,10 @@ pub struct EdgeArgs {
#[clap(long, env, default_value_t = false, requires = "strict")]
pub streaming: bool,

/// If set to true. Edge connects to upstream using delta polling instead of normal polling. This is experimental feature and might and change.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// If set to true. Edge connects to upstream using delta polling instead of normal polling. This is experimental feature and might and change.
/// If set to true. Edge connects to upstream using delta polling instead of normal polling. This is experimental feature and might change.

}


#[cfg(feature = "delta")]
Copy link
Member

Choose a reason for hiding this comment

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

Since you're always adding the impl part, I'm not sure if there's much value in using a feature flag just for tests.

use crate::http::refresher::feature_refresher::FeatureRefresher;
use crate::tokens::cache_key;

impl FeatureRefresher {
Copy link
Member

Choose a reason for hiding this comment

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

Either add #[cfg(feature = "delta")] here, or remove it from the tests part.

@@ -210,7 +218,6 @@ impl UnleashClient {
}
}

#[cfg(test)]
Copy link
Member

Choose a reason for hiding this comment

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

Readding this one seems useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants