Skip to content

Commit e6ecfa0

Browse files
authored
feat(volo): introduce shmipc as transport layer protocol (#636)
* feat(volo): introduce shmipc as transport layer protocol * chore: do not enable shmipc on non-linux environment --------- Signed-off-by: Yu Li <liyu.yukiteru@bytedance.com>
1 parent 5fdef10 commit e6ecfa0

23 files changed

Lines changed: 966 additions & 71 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ jobs:
111111
toolchain: ${{matrix.rust}}
112112
- name: Run tests
113113
run: |
114-
bash scripts/clippy-and-test.sh --no-test
114+
bash scripts/clippy-and-test.sh --no-test --no-shmipc
115115
116116
test-windows:
117117
runs-on: [self-hosted, Windows]
@@ -127,7 +127,7 @@ jobs:
127127
toolchain: ${{matrix.rust}}
128128
- name: Run tests
129129
run: |
130-
bash scripts/clippy-and-test.sh --no-test
130+
bash scripts/clippy-and-test.sh --no-test --no-shmipc
131131
132132
test-cli:
133133
runs-on: [self-hosted, Linux, amd64]
@@ -144,6 +144,7 @@ jobs:
144144
- name: Cli tests
145145
run: |
146146
bash scripts/volo-cli-test.sh
147+
147148
coverage:
148149
runs-on: [self-hosted, Linux, amd64]
149150
timeout-minutes: 40

Cargo.lock

Lines changed: 51 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ metainfo = "0.7.14"
3434

3535
ahash = "0.8"
3636
anyhow = "1"
37+
arc-swap = "1"
3738
async-broadcast = "0.7"
3839
async-stream = "0.3"
3940
base64 = "0.22"
@@ -140,6 +141,8 @@ tokio-native-tls = "0.3"
140141
tungstenite = "0.28"
141142
tokio-tungstenite = "0.28"
142143

144+
shmipc = "0.1"
145+
143146
[profile.release]
144147
opt-level = 3
145148
debug = false

scripts/clippy-and-test.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ set -o errexit
44
set -o nounset
55
set -o pipefail
66

7+
RUN_SHMIPC="yes"
8+
79
echo_command() {
810
echo "$@"
911

@@ -19,6 +21,13 @@ echo_command() {
1921
}
2022

2123
run_clippy() {
24+
echo_command cargo clippy -p volo -- --deny warnings
25+
echo_command cargo clippy -p volo --no-default-features --features rustls-aws-lc-rs -- --deny warnings
26+
echo_command cargo clippy -p volo --no-default-features --features rustls-ring -- --deny warnings
27+
if [ "${RUN_SHMIPC}" = "yes" ]; then
28+
echo_command cargo clippy -p volo --no-default-features --features shmipc -- --deny warnings
29+
echo_command cargo clippy -p volo --no-default-features --features tls,shmipc -- --deny warnings
30+
fi
2231
echo_command cargo clippy -p volo-thrift --no-default-features -- --deny warnings
2332
echo_command cargo clippy -p volo-thrift --no-default-features --features multiplex -- --deny warnings
2433
echo_command cargo clippy -p volo-thrift --no-default-features --features unsafe-codec -- --deny warnings
@@ -33,9 +42,6 @@ run_clippy() {
3342
echo_command cargo clippy -p volo-http --no-default-features --features server,http1,query,form,json,multipart,ws -- --deny warnings
3443
echo_command cargo clippy -p volo-http --no-default-features --features server,http2,query,form,json,multipart,ws -- --deny warnings
3544
echo_command cargo clippy -p volo-http --no-default-features --features full -- --deny warnings
36-
echo_command cargo clippy -p volo -- --deny warnings
37-
echo_command cargo clippy -p volo --no-default-features --features rustls-aws-lc-rs -- --deny warnings
38-
echo_command cargo clippy -p volo --no-default-features --features rustls-ring -- --deny warnings
3945
echo_command cargo clippy -p volo-build -- --deny warnings
4046
echo_command cargo clippy -p volo-cli -- --deny warnings
4147
echo_command cargo clippy -p volo-macros -- --deny warnings
@@ -69,6 +75,10 @@ main() {
6975
RUN_TEST="no"
7076
echo "info: unit tests will be ignored"
7177
;;
78+
--no-shmipc)
79+
RUN_SHMIPC="no"
80+
echo "info: shmipc will be ignored"
81+
;;
7282
esac
7383
done
7484

volo-grpc/src/transport/client.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ fn build_uri(addr: Address, path: &str) -> hyper::Uri {
234234
.path_and_query(path)
235235
.build()
236236
.expect("fail to build unix uri"),
237+
#[allow(unreachable_patterns)]
238+
_ => unimplemented!("unsupported type of address"),
237239
}
238240
}
239241

volo-http/src/client/target.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ impl From<Address> for Target {
323323
}
324324
#[cfg(target_family = "unix")]
325325
Address::Unix(uds) => Target::Local(uds),
326+
#[allow(unreachable_patterns)]
327+
_ => unimplemented!("unsupported type of address"),
326328
}
327329
}
328330
}

volo-http/src/error/client.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ impl ClientError {
100100
Address::Ip(addr) => self.addr = Some(addr),
101101
#[cfg(target_family = "unix")]
102102
Address::Unix(_) => {}
103+
#[allow(unreachable_patterns)]
104+
_ => unimplemented!("unsupported type of address"),
103105
}
104106
self
105107
}

volo-http/src/server/utils/client_ip.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ impl<S> ClientIpService<S> {
217217
Some(Address::Ip(socket_addr)) => Some(socket_addr.ip()),
218218
#[cfg(target_family = "unix")]
219219
Some(Address::Unix(_)) => None,
220+
#[allow(unreachable_patterns)]
221+
Some(_) => unimplemented!("unsupported type of address"),
220222
None => return ClientIp(None),
221223
};
222224

volo-thrift/src/codec/default/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use linkedbytes::LinkedBytes;
3434
use pilota::thrift::ThriftException;
3535
use tokio::io::{AsyncBufReadExt, AsyncRead, AsyncWrite, AsyncWriteExt, Interest};
3636
use tracing::{trace, warn};
37-
use volo::{net::ready::AsyncReady, util::buf_reader::BufReader};
37+
use volo::{net::ext::AsyncExt, util::buf_reader::BufReader};
3838

3939
use self::{framed::MakeFramedCodec, thrift::MakeThriftCodec, ttheader::MakeTTHeaderCodec};
4040
use super::{Decoder, Encoder, MakeCodec};
@@ -118,7 +118,7 @@ pub struct DefaultEncoder<E, W> {
118118
linked_bytes: LinkedBytes,
119119
}
120120

121-
impl<E: ZeroCopyEncoder, W: AsyncWrite + AsyncReady + Unpin + Send + Sync + 'static> Encoder
121+
impl<E: ZeroCopyEncoder, W: AsyncWrite + AsyncExt + Unpin + Send + Sync + 'static> Encoder
122122
for DefaultEncoder<E, W>
123123
{
124124
#[inline]
@@ -203,7 +203,7 @@ pub struct DefaultDecoder<D, R> {
203203
reader: BufReader<R>,
204204
}
205205

206-
impl<D: ZeroCopyDecoder, R: AsyncRead + AsyncReady + Unpin + Send + Sync + 'static> Decoder
206+
impl<D: ZeroCopyDecoder, R: AsyncRead + AsyncExt + Unpin + Send + Sync + 'static> Decoder
207207
for DefaultDecoder<D, R>
208208
{
209209
#[inline]
@@ -290,8 +290,8 @@ impl Default for DefaultMakeCodec<MakeTTHeaderCodec<MakeFramedCodec<MakeThriftCo
290290
impl<MkZC, R, W> MakeCodec<R, W> for DefaultMakeCodec<MkZC>
291291
where
292292
MkZC: MakeZeroCopyCodec,
293-
R: AsyncRead + AsyncReady + Unpin + Send + Sync + 'static,
294-
W: AsyncWrite + AsyncReady + Unpin + Send + Sync + 'static,
293+
R: AsyncRead + AsyncExt + Unpin + Send + Sync + 'static,
294+
W: AsyncWrite + AsyncExt + Unpin + Send + Sync + 'static,
295295
{
296296
type Encoder = DefaultEncoder<MkZC::Encoder, W>;
297297
type Decoder = DefaultDecoder<MkZC::Decoder, R>;

volo/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ maintenance = { status = "actively-developed" }
2626
[dependencies]
2727
motore.workspace = true
2828

29+
arc-swap.workspace = true
2930
async-broadcast.workspace = true
3031
dashmap.workspace = true
3132
faststr.workspace = true
@@ -58,6 +59,7 @@ webpki-roots = { workspace = true, optional = true }
5859
tokio-rustls = { workspace = true, optional = true }
5960
native-tls = { workspace = true, optional = true }
6061
tokio-native-tls = { workspace = true, optional = true }
62+
shmipc = { workspace = true, optional = true }
6163

6264
[features]
6365
default = []
@@ -86,3 +88,5 @@ native-tls = [
8688
"native-tls/alpn",
8789
]
8890
native-tls-vendored = ["native-tls", "tokio-native-tls/vendored"]
91+
92+
shmipc = ["dep:shmipc"]

0 commit comments

Comments
 (0)