Skip to content

Commit

Permalink
fix: fix grpc size limit
Browse files Browse the repository at this point in the history
  • Loading branch information
ZuoTiJia committed Nov 14, 2023
1 parent 5e147ec commit 5814808
Show file tree
Hide file tree
Showing 12 changed files with 1,105 additions and 37 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion common/protos/Cargo.toml
Expand Up @@ -12,7 +12,8 @@ flatbuffers = { workspace = true }
prost = { workspace = true }
rand = { workspace = true }
snafu = { workspace = true }
tonic = { workspace = true }
tonic = { workspace = true, features = ["transport", "tls"] }
tower = { workspace = true }
protobuf = { workspace = true }
async-backtrace = { workspace = true, optional = true }

Expand Down
21 changes: 20 additions & 1 deletion common/protos/src/lib.rs
Expand Up @@ -7,15 +7,23 @@ pub mod test_helper;

use std::collections::HashMap;
use std::fmt::{Display, Formatter};
use std::time::Duration;

use flatbuffers::{FlatBufferBuilder, ForwardsUOffset, WIPOffset};
use flatbuffers::{FlatBufferBuilder, WIPOffset};
use generated::models::Point;
use snafu::Snafu;
use utils::{bitset::BitSet, BkdrHasher};

use crate::kv_service::tskv_service_client::TskvServiceClient;
use crate::models::{
Field, FieldBuilder, FieldType, Points, Schema, SchemaBuilder, Table, Tag, TagBuilder,
};
use flatbuffers::ForwardsUOffset;
use tonic::transport::Channel;
use tower::timeout::Timeout;

// Default 100 MB
pub const DEFAULT_GRPC_SERVER_MESSAGE_LEN: usize = 100 * 1024 * 1024;

type PointsResult<T> = Result<T, PointsError>;

Expand Down Expand Up @@ -655,6 +663,17 @@ pub fn insert_field<'a, 'fbb: 'mut_fbb, 'mut_fbb>(
field_nullbits.set(field_index);
}

pub fn tskv_service_time_out_client(
channel: Channel,
time_out: Duration,
max_message_size: usize,
) -> TskvServiceClient<Timeout<Channel>> {
let timeout_channel = Timeout::new(channel, time_out);
let client = TskvServiceClient::<Timeout<Channel>>::new(timeout_channel);
let client = TskvServiceClient::max_decoding_message_size(client, max_message_size);
TskvServiceClient::max_encoding_message_size(client, max_message_size)
}

#[cfg(test)]
pub mod test {
use utils::bitset::BitSet;
Expand Down

0 comments on commit 5814808

Please sign in to comment.