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 abitiy to store request context #393

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
cc341be
Add back the Client trait, renamed Stub.
tikue Nov 13, 2022
5551108
Add request hooks to the Serve trait.
tikue Nov 8, 2022
7f02cf7
Use rust nightly for Github workflows.
tikue Nov 13, 2022
30710db
Use async fn in generated traits!!
tikue Nov 23, 2022
e23bba7
Replace actions-rs
tikue Nov 24, 2022
ff26d02
Remove bad mem::forget usage.
tikue Nov 24, 2022
3f47cce
Add ability to create a BaseChannel with a Transport dealing with Req…
axos88 Feb 10, 2023
60edf4f
add request sequencer
axos88 Feb 12, 2023
f52cd0f
revert base channel to having unit context, and move the contextual c…
axos88 Feb 12, 2023
416090f
fix merge differences
axos88 Feb 12, 2023
d358a83
revert atomics change to u64
axos88 Feb 13, 2023
c176528
fix formatting
axos88 Feb 13, 2023
33ce197
wip
axos88 Feb 16, 2023
61aa139
Add back the Client trait, renamed Stub.
tikue Nov 13, 2022
2fb75d9
Add request hooks to the Serve trait.
tikue Nov 8, 2022
4e2a499
Use rust nightly for Github workflows.
tikue Nov 13, 2022
e703da5
Use async fn in generated traits!!
tikue Nov 23, 2022
4d24dde
Replace actions-rs
tikue Nov 24, 2022
4031281
Remove bad mem::forget usage.
tikue Nov 24, 2022
b500b72
fix rebase errors
axos88 Apr 10, 2023
a257f3a
Merge branch 'tikuemaster' into typescript
axos88 Apr 10, 2023
404c657
fix
axos88 Apr 10, 2023
f198cfb
wip
axos88 May 4, 2023
f12acc0
remove request sequencer
axos88 May 4, 2023
5f52e5c
wip internal mutability
axos88 May 6, 2023
03a5bf0
revert merge of google/master
axos88 May 6, 2023
d66bf17
revert rename of context to trace_context
axos88 May 6, 2023
cc67311
fixes
axos88 May 6, 2023
02c276a
fix tests
axos88 May 6, 2023
aa65d58
fix compile errors
axos88 Nov 6, 2023
a3874dd
fix tests
axos88 Nov 6, 2023
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
76 changes: 17 additions & 59 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,11 @@ jobs:
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@nightly
with:
profile: minimal
toolchain: stable
target: mipsel-unknown-linux-gnu
override: true
- uses: actions-rs/cargo@v1
with:
command: check
args: --all-features
- uses: actions-rs/cargo@v1
with:
command: check
args: --all-features --target mipsel-unknown-linux-gnu
targets: mipsel-unknown-linux-gnu
- run: cargo check --all-features
- run: cargo check --all-features --target mipsel-unknown-linux-gnu

test:
name: Test Suite
Expand All @@ -42,34 +33,13 @@ jobs:
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: test
- uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path tarpc/Cargo.toml --features serde1
- uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path tarpc/Cargo.toml --features tokio1
- uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path tarpc/Cargo.toml --features serde-transport
- uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path tarpc/Cargo.toml --features tcp
- uses: actions-rs/cargo@v1
with:
command: test
args: --all-features
- uses: dtolnay/rust-toolchain@nightly
- run: cargo test
- run: cargo test --manifest-path tarpc/Cargo.toml --features serde1
- run: cargo test --manifest-path tarpc/Cargo.toml --features tokio1
- run: cargo test --manifest-path tarpc/Cargo.toml --features serde-transport
- run: cargo test --manifest-path tarpc/Cargo.toml --features tcp
- run: cargo test --all-features

fmt:
name: Rustfmt
Expand All @@ -80,16 +50,10 @@ jobs:
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@nightly
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
components: rustfmt
- run: cargo fmt --all -- --check

clippy:
name: Clippy
Expand All @@ -100,13 +64,7 @@ jobs:
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add clippy
- uses: actions-rs/cargo@v1
- uses: dtolnay/rust-toolchain@nightly
with:
command: clippy
args: --all-features -- -D warnings
components: clippy
- run: cargo clippy --all-features -- -D warnings
3 changes: 3 additions & 0 deletions example-service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.

#![allow(incomplete_features)]
#![feature(async_fn_in_trait)]

use std::env;
use tracing_subscriber::{fmt::format::FmtSpan, prelude::*};

Expand Down
10 changes: 8 additions & 2 deletions example-service/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.

#![allow(incomplete_features)]
#![feature(async_fn_in_trait)]

use clap::Parser;
use futures::{future, prelude::*};
use rand::{
Expand Down Expand Up @@ -34,7 +37,6 @@ struct Flags {
#[derive(Clone)]
struct HelloServer(SocketAddr);

#[tarpc::server]
impl World for HelloServer {
async fn hello(self, _: context::Context, name: String) -> String {
let sleep_time =
Expand All @@ -44,6 +46,10 @@ impl World for HelloServer {
}
}

async fn spawn(fut: impl Future<Output = ()> + Send + 'static) {
tokio::spawn(fut);
}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
let flags = Flags::parse();
Expand All @@ -66,7 +72,7 @@ async fn main() -> anyhow::Result<()> {
// the generated World trait.
.map(|channel| {
let server = HelloServer(channel.transport().peer_addr().unwrap());
channel.execute(server.serve())
channel.execute(server.serve()).for_each(spawn)
})
// Max 10 channels.
.buffer_unordered(10)
Expand Down
10 changes: 5 additions & 5 deletions hooks/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ command -v rustup &>/dev/null
if [ "$?" == 0 ]; then
printf "${SUCCESS}\n"

try_run "Building ... " cargo +stable build --color=always
try_run "Testing ... " cargo +stable test --color=always
try_run "Testing with all features enabled ... " cargo +stable test --all-features --color=always
for EXAMPLE in $(cargo +stable run --example 2>&1 | grep ' ' | awk '{print $1}')
try_run "Building ... " cargo build --color=always
try_run "Testing ... " cargo test --color=always
try_run "Testing with all features enabled ... " cargo test --all-features --color=always
for EXAMPLE in $(cargo run --example 2>&1 | grep ' ' | awk '{print $1}')
do
try_run "Running example \"$EXAMPLE\" ... " cargo +stable run --example $EXAMPLE
try_run "Running example \"$EXAMPLE\" ... " cargo run --example $EXAMPLE
done

check_toolchain nightly
Expand Down
Loading