mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-07-30 10:18:41 -04:00
Move json_api to new veilid-remote-api crate
This commit is contained in:
parent
8c817655e8
commit
ad91e93638
19 changed files with 170 additions and 118 deletions
|
@ -37,6 +37,12 @@ search = name = "veilid-tools"
|
||||||
replace = name = "veilid-tools"
|
replace = name = "veilid-tools"
|
||||||
version = "{new_version}"
|
version = "{new_version}"
|
||||||
|
|
||||||
|
[bumpversion:file:veilid-remote-api/Cargo.toml]
|
||||||
|
search = name = "veilid-remote-api"
|
||||||
|
version = "{current_version}"
|
||||||
|
replace = name = "veilid-remote-api"
|
||||||
|
version = "{new_version}"
|
||||||
|
|
||||||
[bumpversion:file:veilid-python/pyproject.toml]
|
[bumpversion:file:veilid-python/pyproject.toml]
|
||||||
search = name = "veilid"
|
search = name = "veilid"
|
||||||
version = "{current_version}"
|
version = "{current_version}"
|
||||||
|
|
|
@ -27,11 +27,11 @@ format:
|
||||||
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||||
changes:
|
changes:
|
||||||
- veilid-*/**/*.rs #Should fire when rust source files are changed
|
- veilid-*/**/*.rs #Should fire when rust source files are changed
|
||||||
- '**/*[Cc]argo*'
|
- "**/*[Cc]argo*"
|
||||||
|
|
||||||
# base earthly setup for jobs
|
# base earthly setup for jobs
|
||||||
.base:
|
.base:
|
||||||
tags: [ saas-linux-medium-amd64 ]
|
tags: [saas-linux-medium-amd64]
|
||||||
image: docker
|
image: docker
|
||||||
services:
|
services:
|
||||||
- docker:dind
|
- docker:dind
|
||||||
|
@ -76,8 +76,7 @@ build_cache:
|
||||||
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||||
changes:
|
changes:
|
||||||
- veilid-*/**/*
|
- veilid-*/**/*
|
||||||
- '**/*[Cc]argo*'
|
- "**/*[Cc]argo*"
|
||||||
|
|
||||||
|
|
||||||
# Runs a basic unit test build, this task will use the `build-cache:latest` as set up in the projects Container Registry
|
# Runs a basic unit test build, this task will use the `build-cache:latest` as set up in the projects Container Registry
|
||||||
test_build:
|
test_build:
|
||||||
|
@ -91,7 +90,7 @@ test_build:
|
||||||
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||||
changes:
|
changes:
|
||||||
- veilid-*/**/*
|
- veilid-*/**/*
|
||||||
- '**/*[Cc]argo*'
|
- "**/*[Cc]argo*"
|
||||||
when: always
|
when: always
|
||||||
- when: never
|
- when: never
|
||||||
|
|
||||||
|
@ -133,8 +132,8 @@ release_job:
|
||||||
script:
|
script:
|
||||||
- echo "running release_job"
|
- echo "running release_job"
|
||||||
release: # See https://docs.gitlab.com/ee/ci/yaml/#release for available properties
|
release: # See https://docs.gitlab.com/ee/ci/yaml/#release for available properties
|
||||||
tag_name: '$CI_COMMIT_TAG'
|
tag_name: "$CI_COMMIT_TAG"
|
||||||
description: '$CI_COMMIT_TAG'
|
description: "$CI_COMMIT_TAG"
|
||||||
rules:
|
rules:
|
||||||
- if: '$CI_COMMIT_TAG =~ /v\d.+/'
|
- if: '$CI_COMMIT_TAG =~ /v\d.+/'
|
||||||
|
|
||||||
|
@ -177,6 +176,8 @@ publish_crates:
|
||||||
- vlt run --command="cargo publish -p veilid-tools"
|
- vlt run --command="cargo publish -p veilid-tools"
|
||||||
- vlt run --command="cargo publish -p veilid-core --dry-run"
|
- vlt run --command="cargo publish -p veilid-core --dry-run"
|
||||||
- vlt run --command="cargo publish -p veilid-core"
|
- vlt run --command="cargo publish -p veilid-core"
|
||||||
|
- vlt run --command="cargo publish -p veilid-remote-api --dry-run"
|
||||||
|
- vlt run --command="cargo publish -p veilid-remote-api"
|
||||||
rules:
|
rules:
|
||||||
- if: '$CI_COMMIT_TAG =~ /v\d.+/'
|
- if: '$CI_COMMIT_TAG =~ /v\d.+/'
|
||||||
|
|
||||||
|
@ -198,7 +199,7 @@ build_repositories:
|
||||||
tags:
|
tags:
|
||||||
- build-orchestration
|
- build-orchestration
|
||||||
variables:
|
variables:
|
||||||
SECURE_FILES_DOWNLOAD_PATH: './'
|
SECURE_FILES_DOWNLOAD_PATH: "./"
|
||||||
script:
|
script:
|
||||||
- curl --silent "https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer" | bash
|
- curl --silent "https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer" | bash
|
||||||
- cp scripts/cicd/build-orchestration/rpm-repo-building/Dockerfile ~/rpm-build-container
|
- cp scripts/cicd/build-orchestration/rpm-repo-building/Dockerfile ~/rpm-build-container
|
||||||
|
@ -279,7 +280,7 @@ dryrun_build_repositories:
|
||||||
tags:
|
tags:
|
||||||
- build-orchestration
|
- build-orchestration
|
||||||
variables:
|
variables:
|
||||||
SECURE_FILES_DOWNLOAD_PATH: './'
|
SECURE_FILES_DOWNLOAD_PATH: "./"
|
||||||
script:
|
script:
|
||||||
- curl --silent "https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer" | bash
|
- curl --silent "https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer" | bash
|
||||||
- cp scripts/cicd/build-orchestration/rpm-repo-building/Dockerfile ~/rpm-build-container
|
- cp scripts/cicd/build-orchestration/rpm-repo-building/Dockerfile ~/rpm-build-container
|
||||||
|
@ -314,7 +315,6 @@ dryrun_delete_build_machines:
|
||||||
rules:
|
rules:
|
||||||
- if: $CI_COMMIT_MESSAGE =~ /\[ci dryrun]/
|
- if: $CI_COMMIT_MESSAGE =~ /\[ci dryrun]/
|
||||||
|
|
||||||
|
|
||||||
# Nightly build pipeline
|
# Nightly build pipeline
|
||||||
|
|
||||||
nightly_create_build_machines:
|
nightly_create_build_machines:
|
||||||
|
@ -349,7 +349,7 @@ nightly_build_repositories:
|
||||||
tags:
|
tags:
|
||||||
- build-orchestration
|
- build-orchestration
|
||||||
variables:
|
variables:
|
||||||
SECURE_FILES_DOWNLOAD_PATH: './'
|
SECURE_FILES_DOWNLOAD_PATH: "./"
|
||||||
script:
|
script:
|
||||||
- curl --silent "https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer" | bash
|
- curl --silent "https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer" | bash
|
||||||
- cp scripts/cicd/build-orchestration/rpm-repo-building/Dockerfile ~/rpm-build-container
|
- cp scripts/cicd/build-orchestration/rpm-repo-building/Dockerfile ~/rpm-build-container
|
||||||
|
|
13
Cargo.lock
generated
13
Cargo.lock
generated
|
@ -6596,6 +6596,18 @@ dependencies = [
|
||||||
"xmltree",
|
"xmltree",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "veilid-remote-api"
|
||||||
|
version = "0.4.6"
|
||||||
|
dependencies = [
|
||||||
|
"parking_lot 0.12.3",
|
||||||
|
"schemars",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"tracing",
|
||||||
|
"veilid-core",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "veilid-server"
|
name = "veilid-server"
|
||||||
version = "0.4.6"
|
version = "0.4.6"
|
||||||
|
@ -6647,6 +6659,7 @@ dependencies = [
|
||||||
"url",
|
"url",
|
||||||
"veilid-bugsalot",
|
"veilid-bugsalot",
|
||||||
"veilid-core",
|
"veilid-core",
|
||||||
|
"veilid-remote-api",
|
||||||
"wg",
|
"wg",
|
||||||
"windows-service",
|
"windows-service",
|
||||||
]
|
]
|
||||||
|
|
|
@ -7,6 +7,7 @@ members = [
|
||||||
"veilid-cli",
|
"veilid-cli",
|
||||||
"veilid-flutter/rust",
|
"veilid-flutter/rust",
|
||||||
"veilid-wasm",
|
"veilid-wasm",
|
||||||
|
"veilid-remote-api",
|
||||||
]
|
]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
|
|
24
Earthfile
24
Earthfile
|
@ -138,20 +138,22 @@ deps-linux:
|
||||||
# Make a cache image with downloaded and built dependencies
|
# Make a cache image with downloaded and built dependencies
|
||||||
build-linux-cache:
|
build-linux-cache:
|
||||||
FROM +deps-linux
|
FROM +deps-linux
|
||||||
RUN mkdir veilid-cli veilid-core veilid-server veilid-tools veilid-wasm veilid-flutter veilid-flutter/rust
|
RUN mkdir -p veilid-cli veilid-core veilid-core/examples/basic veilid-server veilid-tools veilid-wasm veilid-flutter veilid-flutter/rust veilid-remote-api
|
||||||
COPY --keep-ts --dir .cargo scripts Cargo.lock Cargo.toml .
|
COPY --keep-ts --dir .cargo scripts Cargo.lock Cargo.toml .
|
||||||
COPY --keep-ts veilid-cli/Cargo.toml veilid-cli
|
COPY --keep-ts veilid-cli/Cargo.toml veilid-cli
|
||||||
COPY --keep-ts veilid-core/Cargo.toml veilid-core
|
COPY --keep-ts veilid-core/Cargo.toml veilid-core
|
||||||
|
COPY --keep-ts veilid-core/examples/basic/Cargo.toml veilid-core/examples/basic
|
||||||
COPY --keep-ts veilid-server/Cargo.toml veilid-server
|
COPY --keep-ts veilid-server/Cargo.toml veilid-server
|
||||||
COPY --keep-ts veilid-tools/Cargo.toml veilid-tools
|
COPY --keep-ts veilid-tools/Cargo.toml veilid-tools
|
||||||
|
COPY --keep-ts veilid-remote-api/Cargo.toml veilid-remote-api
|
||||||
COPY --keep-ts veilid-flutter/rust/Cargo.toml veilid-flutter/rust
|
COPY --keep-ts veilid-flutter/rust/Cargo.toml veilid-flutter/rust
|
||||||
COPY --keep-ts veilid-wasm/Cargo.toml veilid-wasm/wasm_remap_paths.sh veilid-wasm
|
COPY --keep-ts veilid-wasm/Cargo.toml veilid-wasm/wasm_remap_paths.sh veilid-wasm
|
||||||
RUN cargo chef prepare --recipe-path recipe.json
|
RUN cargo chef prepare --recipe-path recipe.json
|
||||||
RUN cargo chef cook --profile=test --tests --target $DEFAULT_CARGO_TARGET --recipe-path recipe.json -p veilid-server -p veilid-cli -p veilid-tools -p veilid-core
|
RUN cargo chef cook --profile=test --tests --target $DEFAULT_CARGO_TARGET --recipe-path recipe.json -p veilid-server -p veilid-cli -p veilid-tools -p veilid-core -p veilid-remote-api
|
||||||
RUN cargo chef cook --zigbuild --release --target x86_64-unknown-linux-gnu --recipe-path recipe.json -p veilid-server -p veilid-cli -p veilid-tools -p veilid-core
|
RUN cargo chef cook --zigbuild --release --target x86_64-unknown-linux-gnu --recipe-path recipe.json -p veilid-server -p veilid-cli -p veilid-tools -p veilid-core -p veilid-remote-api
|
||||||
RUN cargo chef cook --zigbuild --release --target aarch64-unknown-linux-gnu --recipe-path recipe.json -p veilid-server -p veilid-cli -p veilid-tools -p veilid-core
|
RUN cargo chef cook --zigbuild --release --target aarch64-unknown-linux-gnu --recipe-path recipe.json -p veilid-server -p veilid-cli -p veilid-tools -p veilid-core -p veilid-remote-api
|
||||||
# RUN cargo chef cook --zigbuild --release --target x86_64-pc-windows-gnu --recipe-path recipe.json -p veilid-server -p veilid-cli -p veilid-tools -p veilid-core
|
# RUN cargo chef cook --zigbuild --release --target x86_64-pc-windows-gnu --recipe-path recipe.json -p veilid-server -p veilid-cli -p veilid-tools -p veilid-core -p veilid-remote-api
|
||||||
# RUN cargo chef cook --zigbuild --release --target aarch64-apple-darwin --recipe-path recipe.json -p veilid-server -p veilid-cli -p veilid-tools -p veilid-core
|
# RUN cargo chef cook --zigbuild --release --target aarch64-apple-darwin --recipe-path recipe.json -p veilid-server -p veilid-cli -p veilid-tools -p veilid-core -p veilid-remote-api
|
||||||
RUN veilid-wasm/wasm_remap_paths.sh cargo chef cook --zigbuild --release --target wasm32-unknown-unknown --recipe-path recipe.json -p veilid-wasm
|
RUN veilid-wasm/wasm_remap_paths.sh cargo chef cook --zigbuild --release --target wasm32-unknown-unknown --recipe-path recipe.json -p veilid-wasm
|
||||||
ARG CI_REGISTRY_IMAGE=registry.gitlab.com/veilid/veilid
|
ARG CI_REGISTRY_IMAGE=registry.gitlab.com/veilid/veilid
|
||||||
SAVE IMAGE --push $CI_REGISTRY_IMAGE/build-cache:latest
|
SAVE IMAGE --push $CI_REGISTRY_IMAGE/build-cache:latest
|
||||||
|
@ -170,7 +172,7 @@ code-linux:
|
||||||
FROM $CI_REGISTRY_IMAGE/build-cache:latest
|
FROM $CI_REGISTRY_IMAGE/build-cache:latest
|
||||||
# FROM registry.gitlab.com/veilid/build-cache:latest
|
# FROM registry.gitlab.com/veilid/build-cache:latest
|
||||||
END
|
END
|
||||||
COPY --keep-ts --dir .cargo build_docs.sh files scripts veilid-cli veilid-core veilid-server veilid-tools veilid-flutter veilid-wasm Cargo.lock Cargo.toml /veilid
|
COPY --keep-ts --dir .cargo build_docs.sh files scripts veilid-cli veilid-core veilid-server veilid-tools veilid-flutter veilid-wasm veilid-remote-api Cargo.lock Cargo.toml /veilid
|
||||||
# Check to make sure Cargo.lock is up to date
|
# Check to make sure Cargo.lock is up to date
|
||||||
RUN cargo update -w --locked
|
RUN cargo update -w --locked
|
||||||
# Restore original Cargo.lock
|
# Restore original Cargo.lock
|
||||||
|
@ -179,7 +181,7 @@ code-linux:
|
||||||
# Code + Linux + Android deps
|
# Code + Linux + Android deps
|
||||||
code-android:
|
code-android:
|
||||||
FROM +deps-android
|
FROM +deps-android
|
||||||
COPY --keep-ts --dir .cargo files scripts veilid-cli veilid-core veilid-server veilid-tools veilid-flutter veilid-wasm Cargo.lock Cargo.toml /veilid
|
COPY --keep-ts --dir .cargo files scripts veilid-cli veilid-core veilid-server veilid-tools veilid-flutter veilid-wasm veilid-remote-api Cargo.lock Cargo.toml /veilid
|
||||||
COPY --keep-ts scripts/earthly/cargo-android/config.toml /veilid/.cargo/config.toml
|
COPY --keep-ts scripts/earthly/cargo-android/config.toml /veilid/.cargo/config.toml
|
||||||
|
|
||||||
# Clippy only
|
# Clippy only
|
||||||
|
@ -198,7 +200,7 @@ build-linux-amd64:
|
||||||
RUN echo "not enough container memory to build. increase build host memory."
|
RUN echo "not enough container memory to build. increase build host memory."
|
||||||
RUN false
|
RUN false
|
||||||
END
|
END
|
||||||
RUN cargo zigbuild --locked --target x86_64-unknown-linux-gnu --release -p veilid-server -p veilid-cli -p veilid-tools -p veilid-core
|
RUN cargo zigbuild --locked --target x86_64-unknown-linux-gnu --release -p veilid-server -p veilid-cli -p veilid-tools -p veilid-core -p veilid-remote-api
|
||||||
SAVE ARTIFACT ./target/x86_64-unknown-linux-gnu AS LOCAL ./target/artifacts/x86_64-unknown-linux-gnu
|
SAVE ARTIFACT ./target/x86_64-unknown-linux-gnu AS LOCAL ./target/artifacts/x86_64-unknown-linux-gnu
|
||||||
|
|
||||||
build-linux-arm64:
|
build-linux-arm64:
|
||||||
|
@ -208,7 +210,7 @@ build-linux-arm64:
|
||||||
RUN echo "not enough container memory to build. increase build host memory."
|
RUN echo "not enough container memory to build. increase build host memory."
|
||||||
RUN false
|
RUN false
|
||||||
END
|
END
|
||||||
RUN cargo zigbuild --locked --target aarch64-unknown-linux-gnu --release -p veilid-server -p veilid-cli -p veilid-tools -p veilid-core
|
RUN cargo zigbuild --locked --target aarch64-unknown-linux-gnu --release -p veilid-server -p veilid-cli -p veilid-tools -p veilid-core -p veilid-remote-api
|
||||||
SAVE ARTIFACT ./target/aarch64-unknown-linux-gnu AS LOCAL ./target/artifacts/aarch64-unknown-linux-gnu
|
SAVE ARTIFACT ./target/aarch64-unknown-linux-gnu AS LOCAL ./target/artifacts/aarch64-unknown-linux-gnu
|
||||||
|
|
||||||
# build-windows-amd64:
|
# build-windows-amd64:
|
||||||
|
@ -269,7 +271,7 @@ unit-tests-docs-linux:
|
||||||
|
|
||||||
unit-tests-native-linux:
|
unit-tests-native-linux:
|
||||||
FROM +code-linux
|
FROM +code-linux
|
||||||
RUN cargo test --locked --tests --target $DEFAULT_CARGO_TARGET -p veilid-server -p veilid-cli -p veilid-tools -p veilid-core
|
RUN cargo test --locked --tests --target $DEFAULT_CARGO_TARGET -p veilid-server -p veilid-cli -p veilid-tools -p veilid-core -p veilid-remote-api
|
||||||
|
|
||||||
unit-tests-wasm-linux:
|
unit-tests-wasm-linux:
|
||||||
FROM +code-linux
|
FROM +code-linux
|
||||||
|
|
|
@ -8,6 +8,10 @@ edition.workspace = true
|
||||||
rust-version.workspace = true
|
rust-version.workspace = true
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "basic"
|
||||||
|
path = "./src/main.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tokio = { version = "^1.43.0" }
|
tokio = { version = "^1.43.0" }
|
||||||
veilid-core = { version = "0.4.6", path = "../../../veilid-core" }
|
veilid-core = { version = "0.4.6", path = "../../../veilid-core" }
|
||||||
|
|
|
@ -135,7 +135,7 @@ use eyre::{bail, eyre, Report as EyreReport, Result as EyreResult, WrapErr};
|
||||||
use futures_util::stream::{FuturesOrdered, FuturesUnordered};
|
use futures_util::stream::{FuturesOrdered, FuturesUnordered};
|
||||||
use indent::*;
|
use indent::*;
|
||||||
use parking_lot::*;
|
use parking_lot::*;
|
||||||
use schemars::{schema_for, JsonSchema};
|
use schemars::JsonSchema;
|
||||||
use serde::*;
|
use serde::*;
|
||||||
use stop_token::*;
|
use stop_token::*;
|
||||||
use thiserror::Error as ThisError;
|
use thiserror::Error as ThisError;
|
||||||
|
|
|
@ -5,7 +5,6 @@ mod routing_context;
|
||||||
mod serialize_helpers;
|
mod serialize_helpers;
|
||||||
mod types;
|
mod types;
|
||||||
|
|
||||||
pub mod json_api;
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub mod tests;
|
pub mod tests;
|
||||||
|
|
||||||
|
|
25
veilid-remote-api/Cargo.toml
Normal file
25
veilid-remote-api/Cargo.toml
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
[package]
|
||||||
|
name = "veilid-remote-api"
|
||||||
|
version = "0.4.6"
|
||||||
|
repository.workspace = true
|
||||||
|
authors.workspace = true
|
||||||
|
license.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
rust-version.workspace = true
|
||||||
|
documentation = "https://docs.rs/veilid-remote-api"
|
||||||
|
homepage = "https://veilid.gitlab.io/developer-book/"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/lib.rs"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
veilid-core = { version = "0.4.6", path = "../veilid-core" }
|
||||||
|
|
||||||
|
tracing = { version = "^0", features = ["log", "attributes"] }
|
||||||
|
serde = { version = "1.0.218", features = ["derive", "rc"] }
|
||||||
|
serde_json = { version = "1.0.140" }
|
||||||
|
schemars = "0.8.22"
|
||||||
|
parking_lot = "0.12.3"
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
10
veilid-remote-api/README.md
Normal file
10
veilid-remote-api/README.md
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<!-- DO NOT EDIT BELOW - content within cargo-sync-readme blocks is generated -->
|
||||||
|
<!-- cargo-sync-readme start -->
|
||||||
|
|
||||||
|
# veilid-remote-api
|
||||||
|
|
||||||
|
This crate provides the ability to control a Veilid node remotely.
|
||||||
|
|
||||||
|
The [JsonRequestProcessor] is a wrapper around the [VeilidAPI] and provides a way to process requests and send responses.
|
||||||
|
|
||||||
|
<!-- cargo-sync-readme end -->
|
|
@ -1,4 +1,18 @@
|
||||||
use super::*;
|
//! # veilid-remote-api
|
||||||
|
//!
|
||||||
|
//! This crate provides the ability to control a Veilid node remotely.
|
||||||
|
//!
|
||||||
|
//! The [JsonRequestProcessor] is a wrapper around the [VeilidAPI] and provides a way to process requests and send responses.
|
||||||
|
|
||||||
|
use veilid_core::tools::*;
|
||||||
|
use veilid_core::*;
|
||||||
|
|
||||||
|
use parking_lot::Mutex;
|
||||||
|
use schemars::{schema_for, JsonSchema};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::collections::HashMap;
|
||||||
|
use std::fmt;
|
||||||
|
use tracing::*;
|
||||||
|
|
||||||
mod routing_context;
|
mod routing_context;
|
||||||
pub use routing_context::*;
|
pub use routing_context::*;
|
|
@ -2,55 +2,55 @@ use super::*;
|
||||||
|
|
||||||
pub fn to_json_api_result<T: Clone + fmt::Debug + JsonSchema>(
|
pub fn to_json_api_result<T: Clone + fmt::Debug + JsonSchema>(
|
||||||
r: VeilidAPIResult<T>,
|
r: VeilidAPIResult<T>,
|
||||||
) -> json_api::ApiResult<T> {
|
) -> super::ApiResult<T> {
|
||||||
match r {
|
match r {
|
||||||
Err(e) => json_api::ApiResult::Err { error: e },
|
Err(e) => super::ApiResult::Err { error: e },
|
||||||
Ok(v) => json_api::ApiResult::Ok { value: v },
|
Ok(v) => super::ApiResult::Ok { value: v },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_json_api_result_with_string<T: Clone + fmt::Debug>(
|
pub fn to_json_api_result_with_string<T: Clone + fmt::Debug>(
|
||||||
r: VeilidAPIResult<T>,
|
r: VeilidAPIResult<T>,
|
||||||
) -> json_api::ApiResultWithString<T> {
|
) -> super::ApiResultWithString<T> {
|
||||||
match r {
|
match r {
|
||||||
Err(e) => json_api::ApiResultWithString::Err { error: e },
|
Err(e) => super::ApiResultWithString::Err { error: e },
|
||||||
Ok(v) => json_api::ApiResultWithString::Ok { value: v },
|
Ok(v) => super::ApiResultWithString::Ok { value: v },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_json_api_result_with_vec_string<T: Clone + fmt::Debug>(
|
pub fn to_json_api_result_with_vec_string<T: Clone + fmt::Debug>(
|
||||||
r: VeilidAPIResult<T>,
|
r: VeilidAPIResult<T>,
|
||||||
) -> json_api::ApiResultWithVecString<T> {
|
) -> super::ApiResultWithVecString<T> {
|
||||||
match r {
|
match r {
|
||||||
Err(e) => json_api::ApiResultWithVecString::Err { error: e },
|
Err(e) => super::ApiResultWithVecString::Err { error: e },
|
||||||
Ok(v) => json_api::ApiResultWithVecString::Ok { value: v },
|
Ok(v) => super::ApiResultWithVecString::Ok { value: v },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_json_api_result_with_opt_vec_string<T: Clone + fmt::Debug>(
|
pub fn to_json_api_result_with_opt_vec_string<T: Clone + fmt::Debug>(
|
||||||
r: VeilidAPIResult<T>,
|
r: VeilidAPIResult<T>,
|
||||||
) -> json_api::ApiResultWithOptVecString<T> {
|
) -> super::ApiResultWithOptVecString<T> {
|
||||||
match r {
|
match r {
|
||||||
Err(e) => json_api::ApiResultWithOptVecString::Err { error: e },
|
Err(e) => super::ApiResultWithOptVecString::Err { error: e },
|
||||||
Ok(v) => json_api::ApiResultWithOptVecString::Ok { value: v },
|
Ok(v) => super::ApiResultWithOptVecString::Ok { value: v },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn to_json_api_result_with_vec_u8(r: VeilidAPIResult<Vec<u8>>) -> json_api::ApiResultWithVecU8 {
|
pub fn to_json_api_result_with_vec_u8(r: VeilidAPIResult<Vec<u8>>) -> super::ApiResultWithVecU8 {
|
||||||
match r {
|
match r {
|
||||||
Err(e) => json_api::ApiResultWithVecU8::Err { error: e },
|
Err(e) => super::ApiResultWithVecU8::Err { error: e },
|
||||||
Ok(v) => json_api::ApiResultWithVecU8::Ok { value: v },
|
Ok(v) => super::ApiResultWithVecU8::Ok { value: v },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn to_json_api_result_with_vec_vec_u8(
|
pub fn to_json_api_result_with_vec_vec_u8(
|
||||||
r: VeilidAPIResult<Vec<Vec<u8>>>,
|
r: VeilidAPIResult<Vec<Vec<u8>>>,
|
||||||
) -> json_api::ApiResultWithVecVecU8 {
|
) -> super::ApiResultWithVecVecU8 {
|
||||||
match r {
|
match r {
|
||||||
Err(e) => json_api::ApiResultWithVecVecU8::Err { error: e },
|
Err(e) => super::ApiResultWithVecVecU8::Err { error: e },
|
||||||
Ok(v) => json_api::ApiResultWithVecVecU8::Ok {
|
Ok(v) => super::ApiResultWithVecVecU8::Ok {
|
||||||
value: v.into_iter().map(|v| VecU8 { value: v }).collect(),
|
value: v.into_iter().map(|v| VecU8 { value: v }).collect(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -211,29 +211,6 @@ impl JsonRequestProcessor {
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
|
|
||||||
// Target
|
|
||||||
|
|
||||||
// Parse target
|
|
||||||
fn parse_target(&self, s: String) -> VeilidAPIResult<Target> {
|
|
||||||
// Is this a route id?
|
|
||||||
if let Ok(rrid) = RouteId::from_str(&s) {
|
|
||||||
let routing_table = self.api.core_context()?.routing_table();
|
|
||||||
let rss = routing_table.route_spec_store();
|
|
||||||
|
|
||||||
// Is this a valid remote route id? (can't target allocated routes)
|
|
||||||
if rss.is_route_id_remote(&rrid) {
|
|
||||||
return Ok(Target::PrivateRoute(rrid));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Is this a node id?
|
|
||||||
if let Ok(nid) = TypedNodeId::from_str(&s) {
|
|
||||||
return Ok(Target::NodeId(nid));
|
|
||||||
}
|
|
||||||
|
|
||||||
Err(VeilidAPIError::parse_error("Unable to parse as target", s))
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#[instrument(level = "trace", target = "json_api", skip_all)]
|
#[instrument(level = "trace", target = "json_api", skip_all)]
|
||||||
|
@ -281,7 +258,7 @@ impl JsonRequestProcessor {
|
||||||
result: to_json_api_result_with_vec_u8(
|
result: to_json_api_result_with_vec_u8(
|
||||||
async {
|
async {
|
||||||
routing_context
|
routing_context
|
||||||
.app_call(self.parse_target(target)?, message)
|
.app_call(self.api.parse_as_target(target)?, message)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
.await,
|
.await,
|
||||||
|
@ -293,7 +270,7 @@ impl JsonRequestProcessor {
|
||||||
result: to_json_api_result(
|
result: to_json_api_result(
|
||||||
async {
|
async {
|
||||||
routing_context
|
routing_context
|
||||||
.app_message(self.parse_target(target)?, message)
|
.app_message(self.api.parse_as_target(target)?, message)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
.await,
|
.await,
|
|
@ -55,6 +55,7 @@ geolocation = ["veilid-core/geolocation"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
veilid-core = { path = "../veilid-core", default-features = false }
|
veilid-core = { path = "../veilid-core", default-features = false }
|
||||||
|
veilid-remote-api = { path = "../veilid-remote-api"}
|
||||||
tracing = { version = "^0.1.41", features = ["log", "attributes"] }
|
tracing = { version = "^0.1.41", features = ["log", "attributes"] }
|
||||||
tracing-subscriber = { version = "^0.3.19", features = ["env-filter", "time"] }
|
tracing-subscriber = { version = "^0.3.19", features = ["env-filter", "time"] }
|
||||||
tracing-appender = "^0.2.3"
|
tracing-appender = "^0.2.3"
|
||||||
|
|
|
@ -11,9 +11,9 @@ use std::sync::Arc;
|
||||||
use stop_token::future::FutureExt as _;
|
use stop_token::future::FutureExt as _;
|
||||||
use stop_token::*;
|
use stop_token::*;
|
||||||
use tracing::*;
|
use tracing::*;
|
||||||
use veilid_core::json_api::JsonRequestProcessor;
|
|
||||||
use veilid_core::tools::*;
|
use veilid_core::tools::*;
|
||||||
use veilid_core::*;
|
use veilid_core::*;
|
||||||
|
use veilid_remote_api::JsonRequestProcessor;
|
||||||
use wg::AsyncWaitGroup;
|
use wg::AsyncWaitGroup;
|
||||||
|
|
||||||
const MAX_NON_JSON_LOGGING: usize = 50;
|
const MAX_NON_JSON_LOGGING: usize = 50;
|
||||||
|
@ -251,7 +251,7 @@ impl ClientApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut schemas = HashMap::<String, String>::new();
|
let mut schemas = HashMap::<String, String>::new();
|
||||||
veilid_core::json_api::emit_schemas(&mut schemas);
|
veilid_remote_api::emit_schemas(&mut schemas);
|
||||||
|
|
||||||
let Some(schema) = schemas.get(&args[1]) else {
|
let Some(schema) = schemas.get(&args[1]) else {
|
||||||
apibail_invalid_argument!("invalid schema", "schema", args[1].clone());
|
apibail_invalid_argument!("invalid schema", "schema", args[1].clone());
|
||||||
|
@ -282,18 +282,18 @@ impl ClientApi {
|
||||||
|
|
||||||
// Unmarshal NDJSON - newline => json
|
// Unmarshal NDJSON - newline => json
|
||||||
// (trim all whitespace around input lines just to make things more permissive for API users)
|
// (trim all whitespace around input lines just to make things more permissive for API users)
|
||||||
let request: json_api::Request = deserialize_json(&sanitized_line)?;
|
let request: veilid_remote_api::Request = deserialize_json(&sanitized_line)?;
|
||||||
|
|
||||||
#[cfg(feature = "debug-json-api")]
|
#[cfg(feature = "debug-json-api")]
|
||||||
debug!("JSONAPI: Request: {:?}", request);
|
debug!("JSONAPI: Request: {:?}", request);
|
||||||
|
|
||||||
// See if this is a control message or a veilid-core message
|
// See if this is a control message or a veilid-core message
|
||||||
let response = if let json_api::RequestOp::Control { args } = request.op {
|
let response = if let veilid_remote_api::RequestOp::Control { args } = request.op {
|
||||||
// Process control messages
|
// Process control messages
|
||||||
json_api::Response {
|
veilid_remote_api::Response {
|
||||||
id: request.id,
|
id: request.id,
|
||||||
op: json_api::ResponseOp::Control {
|
op: veilid_remote_api::ResponseOp::Control {
|
||||||
result: json_api::to_json_api_result(self.process_control(args)),
|
result: veilid_remote_api::to_json_api_result(self.process_control(args)),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -306,7 +306,7 @@ impl ClientApi {
|
||||||
|
|
||||||
// Marshal json + newline => NDJSON
|
// Marshal json + newline => NDJSON
|
||||||
let response_string =
|
let response_string =
|
||||||
Arc::new(serialize_json(json_api::RecvMessage::Response(response)) + "\n");
|
Arc::new(serialize_json(veilid_remote_api::RecvMessage::Response(response)) + "\n");
|
||||||
if let Err(e) = responses_tx.send_async(response_string).await {
|
if let Err(e) = responses_tx.send_async(response_string).await {
|
||||||
eprintln!("response not sent: {}", e)
|
eprintln!("response not sent: {}", e)
|
||||||
}
|
}
|
||||||
|
@ -375,7 +375,7 @@ impl ClientApi {
|
||||||
{
|
{
|
||||||
// Make request processor for this connection
|
// Make request processor for this connection
|
||||||
let api = self.inner.lock().veilid_api.clone();
|
let api = self.inner.lock().veilid_api.clone();
|
||||||
let jrp = json_api::JsonRequestProcessor::new(api);
|
let jrp = veilid_remote_api::JsonRequestProcessor::new(api);
|
||||||
|
|
||||||
// Futures to process unordered
|
// Futures to process unordered
|
||||||
let mut unord = FuturesUnordered::new();
|
let mut unord = FuturesUnordered::new();
|
||||||
|
@ -533,7 +533,7 @@ impl ClientApi {
|
||||||
|
|
||||||
// serialize update to NDJSON
|
// serialize update to NDJSON
|
||||||
let veilid_update =
|
let veilid_update =
|
||||||
Arc::new(serialize_json(json_api::RecvMessage::Update(veilid_update)) + "\n");
|
Arc::new(serialize_json(veilid_remote_api::RecvMessage::Update(veilid_update)) + "\n");
|
||||||
|
|
||||||
// Pass updates to clients
|
// Pass updates to clients
|
||||||
for ch in inner.update_channels.values() {
|
for ch in inner.update_channels.values() {
|
||||||
|
|
|
@ -446,7 +446,7 @@ fn main() -> EyreResult<()> {
|
||||||
// -- Emit JSON-Schema --
|
// -- Emit JSON-Schema --
|
||||||
if let Some(esstr) = args.emit_schema {
|
if let Some(esstr) = args.emit_schema {
|
||||||
let mut schemas = HashMap::<String, String>::new();
|
let mut schemas = HashMap::<String, String>::new();
|
||||||
veilid_core::json_api::emit_schemas(&mut schemas);
|
veilid_remote_api::emit_schemas(&mut schemas);
|
||||||
|
|
||||||
if let Some(schema) = schemas.get(&esstr) {
|
if let Some(schema) = schemas.get(&esstr) {
|
||||||
println!("{}", schema);
|
println!("{}", schema);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Fail out if any step has an error
|
# Fail out if any step has an error
|
||||||
set -e
|
set -ex
|
||||||
|
|
||||||
if [ "$1" == "patch" ]; then
|
if [ "$1" == "patch" ]; then
|
||||||
echo Bumping patch version
|
echo Bumping patch version
|
||||||
|
@ -25,7 +25,7 @@ NEW_VERSION=$(cat .bumpversion.cfg | grep current_version\ = | cut -d\ -f3)
|
||||||
echo NEW_VERSION=$NEW_VERSION
|
echo NEW_VERSION=$NEW_VERSION
|
||||||
|
|
||||||
# Update crate dependencies for the crates we publish
|
# Update crate dependencies for the crates we publish
|
||||||
cargo upgrade -p veilid-tools@$NEW_VERSION -p veilid-core@$NEW_VERSION
|
cargo upgrade -p veilid-tools@$NEW_VERSION -p veilid-core@$NEW_VERSION -p veilid-remote-api@$NEW_VERSION
|
||||||
|
|
||||||
# Update lockfile
|
# Update lockfile
|
||||||
cargo update
|
cargo update -w
|
Loading…
Add table
Add a link
Reference in a new issue