-
Notifications
You must be signed in to change notification settings - Fork 5
feat: Add Support for Fastly Compute@Edge (WASM) #33
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
base: main
Are you sure you want to change the base?
Conversation
- updates reqwest dependency to not include blocking feature - adds features - "default" enables the reqwest/blocking feature - "non_blocking" enables the fastly module - throw compilation error if both default and non_blocking features are active - adds abstraction for "client" interaction - SafeClient struct contains (based on feature flags) - a wrapper around reqwest::blocking::Client - or a struct to act as a Client for making requests via fastly::http::Request - updates implementation of mod.rs and analytics.rs to consume new abstraction struct - still need to update error handling/types/etc
- fix constructor call for FastlyClient
- remove stray whitespace from Cargo.toml - remove commented code from analytics.rs
- update FastlyClient to actually set the headers on the request
Thanks for the PR @aturingmachine, we'll give it a review as soon as we can. |
Awesome, thanks! If need be I can try to find some time to get all the unit testing stuff set up for using the If the splitting between using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks for this — it looks really good. The overhead of maintaining two different libs (one with reqwest and another with fastly) will be a bit much. I think the best path forward would be to add unit tests for the Fastly part of the code, and maybe in the future we can get rid of reqwest and use http (used by Fastly) directly.
- adds plumbing to run fastly depended specs via viceroy - swaps from using feature flags to using architecture cfg flags - these play nicer with nextest - also allows us to exclude httpmock from the dev deps if we are targeting wasm as httpmock does not support wasm - updates existing unit tests to be cfg flagged - excludes them from compilation if the target is wasm - im sorry but i could not find another way to accomplish this
Ok I have updated this to add the "plumbing" to run unit tests on the fastly dependent code. This was a bigger change than I anticipated as I had to swap from using feature flags to using the build target for the flag. This is required me to completely exclude all the existing tests from the I am unsure of the preferred way to split these tests up, so I have added some scripts:
Where this sits now should be a good enough place to figure out a way to write some integration tests for the Should also note I have not tested this "in the wild" at all, and the code currently assumes that implementer has a fastly compute backend named |
Thanks, @aturingmachine,I will keep this open for now as a reference for anyone else looking to run our SDK on Fastly, and I’ll pick it up once we’re done with the major refactoring work (currently going on) across our SDKs and have tested this enough to feel confident about adding it to the main branch. |
Summary
Attempts to add support for using the Flagsmith Rust SDK on the Fastly Compute@Edge platform.
This PR does not add the needed support for running Unit Tests on the main crate while compiling it to target Compute@Edge; more information is provided in the Notes section.Problem
Related to #28.
wasm
and using theblocking
feature of thereqwest
crate.reqwest::blocking
cannot run in an async runtime such aswasm
.fastly
crate (as far as I know)viceroy
.Solution
Plan is to apply an abstraction over the
reqwest::blocking::Client
and a "Client shaped" wrapper aroundfastly::http::Request
in order to avoid making too many modifications to the core SDK code.In order to resolve the compilation issues anything making use of
reqwest::blocking
andhttpmock
have been flagged to compile IFFnot(target = "wasm")
, whereas the inversetarget = "wasm"
has been applied to thefastly
dependent code.Notes
cargo test
(for thedefault
features) are passing,however running unit tests with thefastly
crate enabled will require the addition ofviceroy
and running the tests viacargo-nextest
, and quite a bit of scaffolding work that I am unsure if this package wants to take on.cargo test
cargo nextest run --target wasm32-wasip1 flagsmith::client
; or by running./scripts/fastly-unit-test.sh
scripts/test.sh
will run both platforms of unit testsLinks
viceroy
cargo-nextest