Skip to content
Open
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
33 changes: 25 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
clippy:
name: Clippy
runs-on: ubuntu-latest
timeout-minutes: 45
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
Expand All @@ -37,6 +37,7 @@ jobs:
fmt:
name: Rust fmt
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
Expand All @@ -47,14 +48,15 @@ jobs:

deny:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: EmbarkStudios/cargo-deny-action@v2

doc:
name: Documentation
runs-on: ubuntu-latest
timeout-minutes: 45
timeout-minutes: 30
env:
RUSTDOCFLAGS: -Dwarnings
steps:
Expand All @@ -63,30 +65,45 @@ jobs:
with:
toolchain: stable
components: rustfmt
- run: cargo doc --color=always --verbose --no-deps
- run: cargo doc --all-features --color=always --verbose --workspace --no-deps

build:
runs-on: ubuntu-latest
timeout-minutes: 45
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: rustc-dev
- run: cargo check --benches --all-features --release
- run: cargo check --workspace --tests --all-features --release

doc_test:
name: Doc tests
needs: build
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: llvm-tools, rustc-dev
- run: >
cargo test --doc
--verbose --color always
--workspace --no-fail-fast

test:
name: Tests
needs: build
runs-on: ubuntu-latest
timeout-minutes: 45
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: llvm-tools, rustc-dev
- run: >
cargo test --all-features --release
--tests --verbose --color always
cargo test --release --tests
--verbose --color always
--workspace --no-fail-fast
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "prosa-hyper"
version = "0.2.0"
version = "0.3.0"
authors = ["Jérémy HERGAULT <[email protected]>", "Anthony THOMAS <[email protected]>", "Julien TERUEL <[email protected]>", "Rene-Louis EYMARD <[email protected]>"]
description = "ProSA Hyper processor for HTTP client/server"
homepage = "https://worldline.com/"
Expand All @@ -20,10 +20,10 @@ adaptor = ["server::adaptor::HelloHyperServerAdaptor"]
bytes = "1"
thiserror = "2"
serde = { version = "1", features = ["derive"] }
tokio = { version = "1", features = ["macros", "net", "rt", "rt-multi-thread"] }
tokio = { version = ">=1.48, < 2", features = ["macros", "net", "rt", "rt-multi-thread"] }
tracing = "0.1"
prosa-utils = "0.3"
prosa = "0.3"
prosa-utils = "0.4"
prosa = "0.4"
aquamarine = "0.6"
url = { version = "2", features = ["serde"] }

Expand All @@ -34,7 +34,7 @@ http-body-util = "0.1"
hyper-util = { version = "0.1", features = ["full"] }

[dev-dependencies]
openssl = "0.10"
openssl = ">=0.10.75, < 0.11"
reqwest = { version = "0.12", features = ["rustls-tls"] }
config = { version = "0.15", default-features = false, features = ["toml", "json", "yaml", "json5", "convert-case", "async"] }
clap = "4"
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# ProSA Hyper

[<img alt="github" src="https://img.shields.io/badge/github-46beaa?style=for-the-badge&labelColor=555555&logo=github" height="20">](https://github.com/worldline/ProSA-Hyper)
[<img alt="crates-io" src="https://img.shields.io/badge/crates.io-ffeb78?style=for-the-badge&labelColor=555555&logo=rust" height="20">](https://crates.io/crates/prosa-hyper)
[<img alt="docs-rs" src="https://img.shields.io/badge/docs.rs-41b4d2?style=for-the-badge&labelColor=555555&logo=docs.rs" height="20">](https://docs.rs/prosa-hyper)
[<img alt="build status" src="https://img.shields.io/github/actions/workflow/status/worldline/ProSA-Hyper/ci.yml?branch%3Amain&style=for-the-badge" height="20">](https://github.com/worldline/ProSA-Hyper/actions?query=branch%3Amain)
[<img alt="dependency status" src="https://img.shields.io/deps-rs/repo/github/worldline/ProSA-Hyper?style=for-the-badge" height="20">](https://deps.rs/repo/github/worldline/ProSA-Hyper)

[ProSA](https://github.com/worldline/ProSA) Hyper processor for HTTP client/server build on [Hyper](https://hyper.rs/), a Tokio implementation of HTTP.

## Use
Expand Down Expand Up @@ -30,6 +36,8 @@ http_server:
passphrase: MySuperPassphrase
```

If you have some slow services, you can set the `service_timeout` parameter (800 ms by default).

## Examples

### Server
Expand Down
38 changes: 26 additions & 12 deletions examples/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use hyper::{Request, Response};
use prosa::core::adaptor::Adaptor;
use prosa::core::error::ProcError;
use prosa::core::main::MainRunnable as _;
use prosa::core::proc::{Proc, ProcConfig};
use prosa::core::proc::{Proc, ProcBusParam as _, ProcConfig};
use prosa::core::settings::settings;
use prosa::stub::adaptor::StubParotAdaptor;
use prosa::stub::proc::StubSettings;
Expand Down Expand Up @@ -41,12 +41,9 @@ where
+ prosa_utils::msg::tvf::Tvf
+ std::default::Default,
{
fn new(
_proc: &HyperServerProc<M>,
prosa_name: &str,
) -> Result<Self, Box<dyn ProcError + Send + Sync>> {
fn new(proc: &HyperServerProc<M>) -> Result<Self, Box<dyn ProcError + Send + Sync>> {
Ok(HyperDemoAdaptor {
prosa_name: prosa_name.into(),
prosa_name: proc.name().to_string(),
})
}

Expand All @@ -57,6 +54,10 @@ where
match req.uri().path() {
"/" => HyperResp::HttpResp(
Response::builder()
.header(
"Server",
<HyperDemoAdaptor as HyperServerAdaptor<M>>::SERVER_HEADER,
)
.body(BoxBody::new(Full::new(Bytes::from(format!(
"{} - Home of {}",
if req.version() == hyper::Version::HTTP_2 {
Expand All @@ -77,6 +78,10 @@ where
_ => HyperResp::HttpResp(
Response::builder()
.status(404)
.header(
"Server",
<HyperDemoAdaptor as HyperServerAdaptor<M>>::SERVER_HEADER,
)
.body(BoxBody::new(Full::new(Bytes::from("Not Found"))))
.unwrap(),
),
Expand Down Expand Up @@ -137,22 +142,31 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
prosa_hyper_settings.observability.tracing_init(&filter)?;

// Create bus and main processor
let (bus, main) = MainProc::<SimpleStringTvf>::create(&prosa_hyper_settings);
let (bus, main) = MainProc::<SimpleStringTvf>::create(&prosa_hyper_settings, Some(2));

// Launch the main task
debug!("Launch the main task");
let main_task = main.run();

debug!("Start the Hyper processor");
let http_proc =
HyperServerProc::<SimpleStringTvf>::create(1, bus.clone(), prosa_hyper_settings.hyper);
Proc::<HyperDemoAdaptor>::run(http_proc, String::from("hyper"));
let http_proc = HyperServerProc::<SimpleStringTvf>::create(
1,
String::from("hyper"),
bus.clone(),
prosa_hyper_settings.hyper,
);
Proc::<HyperDemoAdaptor>::run(http_proc);

if matches.contains_id("stub") && matches.get_flag("stub") {
debug!("Start a Stub processor");
let stub_settings = StubSettings::new(vec![String::from("SRV_TEST")]);
let stub_proc = StubProc::<SimpleStringTvf>::create(2, bus.clone(), stub_settings);
Proc::<StubParotAdaptor>::run(stub_proc, String::from("STUB_PROC"));
let stub_proc = StubProc::<SimpleStringTvf>::create(
2,
String::from("STUB_PROC"),
bus.clone(),
stub_settings,
);
Proc::<StubParotAdaptor>::run(stub_proc);
}

// Wait on main task
Expand Down
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/COPYRIGHT"))]
//!
//! [![github]](https://github.com/worldline/ProSA-Hyper)&ensp;[![crates-io]](https://crates.io/crates/prosa-hyper)&ensp;[![docs-rs]](crate)
//!
//! [github]: https://img.shields.io/badge/github-46beaa?style=for-the-badge&labelColor=555555&logo=github
//! [crates-io]: https://img.shields.io/badge/crates.io-ffeb78?style=for-the-badge&labelColor=555555&logo=rust
//! [docs-rs]: https://img.shields.io/badge/docs.rs-41b4d2?style=for-the-badge&labelColor=555555&logo=docs.rs
//!
//! ProSA Hyper processor to handle HTTP client and server

#![warn(missing_docs)]
Expand Down
Loading