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 gzip encoding to firehose GRPC stream requests #3893

Merged
merged 4 commits into from
Sep 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
22 changes: 21 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions graph/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ tokio-retry = "0.3.0"
url = "2.2.1"
prometheus = "0.13.1"
priority-queue = "0.7.0"
tonic = { version = "0.7.1", features = ["tls-roots"] }
tonic = { version = "0.7.1", features = ["tls-roots","compression"] }
prost = "0.10.4"
prost-types = "0.10.1"

Expand All @@ -70,4 +70,4 @@ maplit = "1.0.2"
structopt = { version = "0.3" }

[build-dependencies]
tonic-build = { version = "0.7.2", features = ["prost"] }
tonic-build = { version = "0.7.2", features = ["prost","compression"] }
8 changes: 6 additions & 2 deletions graph/src/firehose/endpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ impl FirehoseEndpoint {

Ok(r)
},
);
)
.accept_gzip()
.send_gzip();

debug!(
logger,
Expand Down Expand Up @@ -208,7 +210,9 @@ impl FirehoseEndpoint {

Ok(r)
},
);
)
.accept_gzip()
.send_gzip();

let response_stream = client.blocks(request).await?;
let block_stream = response_stream.into_inner();
Expand Down
16 changes: 14 additions & 2 deletions graph/src/firehose/sf.firehose.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ pub mod stream_server {
#[derive(Debug)]
pub struct StreamServer<T: Stream> {
inner: _Inner<T>,
accept_compression_encodings: (),
send_compression_encodings: (),
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
}
struct _Inner<T>(Arc<T>);
impl<T: Stream> StreamServer<T> {
Expand All @@ -223,6 +223,18 @@ pub mod stream_server {
{
InterceptedService::new(Self::new(inner), interceptor)
}
/// Enable decompressing requests with `gzip`.
#[must_use]
pub fn accept_gzip(mut self) -> Self {
self.accept_compression_encodings.enable_gzip();
self
}
/// Compress responses with `gzip`, if the client supports it.
#[must_use]
pub fn send_gzip(mut self) -> Self {
self.send_compression_encodings.enable_gzip();
self
}
}
impl<T, B> tonic::codegen::Service<http::Request<B>> for StreamServer<T>
where
Expand Down
16 changes: 14 additions & 2 deletions graph/src/substreams/sf.substreams.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,8 @@ pub mod stream_server {
#[derive(Debug)]
pub struct StreamServer<T: Stream> {
inner: _Inner<T>,
accept_compression_encodings: (),
send_compression_encodings: (),
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
}
struct _Inner<T>(Arc<T>);
impl<T: Stream> StreamServer<T> {
Expand All @@ -507,6 +507,18 @@ pub mod stream_server {
{
InterceptedService::new(Self::new(inner), interceptor)
}
/// Enable decompressing requests with `gzip`.
#[must_use]
pub fn accept_gzip(mut self) -> Self {
self.accept_compression_encodings.enable_gzip();
self
}
/// Compress responses with `gzip`, if the client supports it.
#[must_use]
pub fn send_gzip(mut self) -> Self {
self.send_compression_encodings.enable_gzip();
self
}
}
impl<T, B> tonic::codegen::Service<http::Request<B>> for StreamServer<T>
where
Expand Down