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

add lookup app by id #6

Merged
merged 2 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 34 additions & 34 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,37 +47,37 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}

coverage:
needs: build
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/main'
steps:
- name: Clone repo
uses: actions/checkout@v4
with:
submodules: recursive

- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true

- uses: actions-rs/cargo@v1
name: Run test with code coverage report
with:
command: test
args: --workspace --all-features --no-fail-fast
env:
CARGO_INCREMENTAL: '0'
RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'

- id: coverage
name: Collect code coverage
uses: actions-rs/grcov@v0.1

- name: Archive code coverage results
uses: actions/upload-artifact@v4
with:
name: code-coverage-report
path: ${{ steps.coverage.outputs.report }}
# coverage:
# needs: build
# runs-on: ubuntu-latest
# if: github.ref != 'refs/heads/main'
# steps:
# - name: Clone repo
# uses: actions/checkout@v4
# with:
# submodules: recursive
#
# - uses: actions-rs/toolchain@v1
# with:
# toolchain: nightly
# override: true
#
# - uses: actions-rs/cargo@v1
# name: Run test with code coverage report
# with:
# command: test
# args: --workspace --all-features --no-fail-fast
# env:
# CARGO_INCREMENTAL: '0'
# RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
# RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
#
# - id: coverage
# name: Collect code coverage
# uses: actions-rs/grcov@v0.1
#
# - name: Archive code coverage results
# uses: actions/upload-artifact@v4
# with:
# name: code-coverage-report
# path: ${{ steps.coverage.outputs.report }}
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = ["crates/*"]
resolver = "2"

[workspace.package]
version = "0.3.8"
version = "0.3.9"
edition = "2021"
publish = false
authors = ["FastEdge Development Team"]
Expand Down
4 changes: 2 additions & 2 deletions crates/http-service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ where
app_name,
request.uri()
);
let cfg = match self.context.lookup(&app_name).await {
let cfg = match self.context.lookup_by_name(&app_name).await {
None => {
#[cfg(feature = "metrics")]
metrics::metrics(AppResult::UNKNOWN);
Expand Down Expand Up @@ -612,7 +612,7 @@ mod tests {
}

impl Router for TestContext {
async fn lookup(&self, _name: &str) -> Option<App> {
async fn lookup_by_name(&self, _name: &str) -> Option<App> {
self.app.clone()
}
}
Expand Down
3 changes: 2 additions & 1 deletion crates/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@ pub trait ExecutorCache {
}

pub trait Router: Send + Sync {
fn lookup(&self, name: &str) -> impl std::future::Future<Output = Option<App>> + Send;
fn lookup_by_name(&self, name: &str) -> impl std::future::Future<Output = Option<App>> + Send;
fn lookup_by_id(&self, id: u64) -> impl std::future::Future<Output = Option<App>> + Send;
}

pub fn componentize_if_necessary(buffer: &[u8]) -> anyhow::Result<Cow<[u8]>> {
Expand Down
6 changes: 5 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,13 @@ impl ContextHeaders for CliContext<'_> {
}

impl Router for CliContext<'_> {
async fn lookup(&self, _name: &str) -> Option<App> {
async fn lookup_by_name(&self, _name: &str) -> Option<App> {
self.app.to_owned()
}

async fn lookup_by_id(&self, _id: u64) -> Option<App> {
unreachable!()
}
}

impl StatsWriter for CliContext<'_> {
Expand Down
Loading