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

Feature: Managed Assets #22

Merged
merged 76 commits into from
Jul 10, 2022
Merged

Feature: Managed Assets #22

merged 76 commits into from
Jul 10, 2022

Conversation

sgammon
Copy link
Member

@sgammon sgammon commented Jul 3, 2022

Ready for review Powered by Pull Request Badge

This changeset introduces a managed asset layer to Elide, which is integrated into the framework build tools. At build time, embedded SSR and CSR assets are packaged into the application, and are now additionally embedded with an asset descriptor providing metadata and dependency info.

These descriptors are then used at runtime to more efficiently serve static assets directly out of memory, and to reference static assets easily from dynamic contexts.

Later, we can use this as groundwork to enable dependency-aware asset serving, on-the-fly compilation, and so on.

Changelog

  • Add AssetManager, AssetReader, AssetResolver interfaces
  • Add initial abstract logic for resolving and serving assets
  • Add server configuration properties for the asset system
  • Add concept of general bundled asset to bundle.proto
  • Add built-in implementations for each asset component interface
  • Add initial implementation of controller for asset serving
  • Logic to translate assets into HTTP responses
  • Logic to load and read assets
  • Tests for asset components
  • Tests for asset controller
  • Gradle plugin support
  • Pre-compressed asset serving
  • Support for ETags (If-None-Match / 304)

This changeset introduces a managed asset layer to Elide, which is
integrated into the framework build tools. At build time, embedded
SSR and CSR assets are packaged into the application, and are now
additionally embedded with an asset descriptor providing metadata
and dependency info.

These descriptors are then used at runtime to more efficiently
serve static assets directly out of memory, and to reference static
assets easily from dynamic contexts.

Later, we can use this as groundwork to enable dependency-aware
asset serving, on-the-fly compilation, and so on.

Changes enclosed:
- Add `AssetManager`, `AssetReader`, `AssetResolver` interfaces
- Add initial abstract logic for resolving and serving assets
- Add server configuration properties for the asset system
- Add concept of general bundled asset to `bundle.proto`
- Add built-in implementations for each asset component interface
- Add initial implementation of controller for asset serving

Changes pending:
- Logic to translate assets into HTTP responses
- Logic to load and read assets
- Tests for asset components
- Tests for asset controller
- Gradle plugin support
@sgammon sgammon added java Pull requests that update Java code module:server Modules, changes, and issues relating to Elide for servers feature Large PRs or issues with full-blown features platform:jvm PRs and issues relating to JVM support. 🚧 WIP Works-in-progress. Blocks merge labels Jul 3, 2022
@sgammon sgammon added this to the Alpha 1: Initial Release milestone Jul 3, 2022
@sgammon sgammon self-assigned this Jul 3, 2022
sgammon added a commit to elide-dev/plugin-gradle that referenced this pull request Jul 4, 2022
This changeset moves the JS bundle task for Elide SSR into the
plugin, behind an `elide {}` extension. The extension is
configurable in terms of tooling, target, and build mode.

Integrated with elide-dev/elide#22.

Changes enclosed:
- Implement `esbuild` config-gen and build
- Implement configuration of plugin via extension, etc
- Add support for pre-compiling SSR bundle via Prepack
- Update protos to account for embedded/generic assets
- Plugin version bump -> `1.0.0-alpha2`

Pending changes:
- Avoid requiring `npm(...)` deps and `node {}` block in
  downstream projects
@sgammon sgammon linked an issue Jul 4, 2022 that may be closed by this pull request
@codecov-commenter
Copy link

codecov-commenter commented Jul 4, 2022

Codecov Report

Merging #22 (923968b) into v3 (d8f3b58) will increase coverage by 6.15%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##                 v3      #22      +/-   ##
============================================
+ Coverage     44.21%   50.37%   +6.15%     
- Complexity      166      271     +105     
============================================
  Files            41       59      +18     
  Lines          1825     2289     +464     
  Branches        171      210      +39     
============================================
+ Hits            807     1153     +346     
- Misses          997     1099     +102     
- Partials         21       37      +16     
Impacted Files Coverage Δ
...server/src/main/kotlin/elide/server/Application.kt 0.00% <0.00%> (ø)
...alvm/src/main/kotlin/elide/server/SSRExtensions.kt 0.00% <0.00%> (ø)
...ver/src/main/kotlin/elide/server/PageExtensions.kt 0.00% <0.00%> (ø)
...src/main/kotlin/elide/server/ResponseExtensions.kt 0.00% <0.00%> (ø)
.../main/kotlin/elide/server/ssr/ServerSSRRenderer.kt 0.00% <0.00%> (ø)
...main/kotlin/elide/server/assets/AssetController.kt 90.00% <0.00%> (ø)
...src/main/kotlin/elide/server/assets/AssetReader.kt 100.00% <0.00%> (ø)
...s/test/src/jvmMain/kotlin/elide/server/TestUtil.kt 40.00% <0.00%> (ø)
...c/main/kotlin/elide/server/assets/AssetResolver.kt 100.00% <0.00%> (ø)
...in/kotlin/elide/server/assets/ServerAssetReader.kt 55.22% <0.00%> (ø)
... and 16 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d8f3b58...923968b. Read the comment docs.

@sgammon sgammon marked this pull request as ready for review July 10, 2022 06:59
- Select best pre-compressed asset from available set, if declared
  as supported by client
- Generate ETag values for assets when enabled
- Respond to If-Not-Modified requests appropriately when enabled
@sonarcloud
Copy link

sonarcloud bot commented Jul 10, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@sgammon sgammon merged commit 10adee8 into v3 Jul 10, 2022
@sgammon sgammon deleted the feat/assets branch July 10, 2022 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:buf-breaking-ignore Ignore breaking proto changes feature Large PRs or issues with full-blown features java Pull requests that update Java code module:server Modules, changes, and issues relating to Elide for servers platform:jvm PRs and issues relating to JVM support. 🚧 WIP Works-in-progress. Blocks merge
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Managed Assets
2 participants