Skip to content

Commit

Permalink
fix: override encoding and decoding sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
Vilsol committed Apr 26, 2024
1 parent 456ecd4 commit 2673276
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cfg/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"server": {
"host": "0.0.0.0",
"port": 50062,
"message_size_limit": 16777215
"message_size_limit": 64000000
},

"s3": {
Expand Down
18 changes: 14 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::str::FromStr;
use std::{env, error::Error, net::ToSocketAddrs};
use tokio::sync::mpsc;

use tonic::codegen::InterceptedService;
use tonic::{transport::Server, Request, Status};
use tonic_health::ServingStatus;

Expand Down Expand Up @@ -60,13 +61,22 @@ async fn main() -> Result<(), Box<dyn Error>> {

start_renderer(rx).await?;

let pdf_service =
InterceptedService::new(
PdfRenderingServiceServer::new(pdf_server)
.max_decoding_message_size(
config.get_int("server.message_size_limit").unwrap() as usize
)
.max_encoding_message_size(
config.get_int("server.message_size_limit").unwrap() as usize
),
logging,
);

let server = Server::builder()
.max_frame_size(config.get_int("server.message_size_limit").map(|t| { t as u32 }).ok())
.add_service(health_service)
.add_service(reflection_service)
.add_service(PdfRenderingServiceServer::with_interceptor(
pdf_server, logging,
))
.add_service(pdf_service)
.serve(
(format!(
"{}:{}",
Expand Down

0 comments on commit 2673276

Please sign in to comment.