flow/batching_mode.rs
1// Copyright 2023 Greptime Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Run flow as batching mode which is time-window-aware normal query triggered when new data arrives
16
17use std::time::Duration;
18
19use common_grpc::channel_manager::ClientTlsOption;
20use serde::{Deserialize, Serialize};
21use session::ReadPreference;
22
23mod checkpoint;
24pub(crate) mod engine;
25pub(crate) mod frontend_client;
26mod state;
27mod table_creator;
28mod task;
29mod time_window;
30pub(crate) mod utils;
31
32#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
33pub struct BatchingModeOptions {
34 /// The default batching engine query timeout is 10 minutes
35 #[serde(with = "humantime_serde")]
36 pub query_timeout: Duration,
37 /// will output a warn log for any query that runs for more that this threshold
38 #[serde(with = "humantime_serde")]
39 pub slow_query_threshold: Duration,
40 /// The minimum duration between two queries execution by batching mode task
41 #[serde(with = "humantime_serde")]
42 pub experimental_min_refresh_duration: Duration,
43 /// The gRPC connection timeout
44 #[serde(with = "humantime_serde")]
45 pub grpc_conn_timeout: Duration,
46 /// The gRPC max retry number
47 pub experimental_grpc_max_retries: u32,
48 /// Flow wait for available frontend timeout,
49 /// if failed to find available frontend after frontend_scan_timeout elapsed, return error
50 /// which prevent flownode from starting
51 #[serde(with = "humantime_serde")]
52 pub experimental_frontend_scan_timeout: Duration,
53 /// Maximum number of filters allowed in a single query
54 pub experimental_max_filter_num_per_query: usize,
55 /// Time window merge distance
56 pub experimental_time_window_merge_threshold: usize,
57 /// Read preference of the Frontend client.
58 pub read_preference: ReadPreference,
59 /// TLS option for client connections to frontends.
60 pub frontend_tls: Option<ClientTlsOption>,
61}
62
63impl Default for BatchingModeOptions {
64 fn default() -> Self {
65 Self {
66 query_timeout: Duration::from_secs(10 * 60),
67 slow_query_threshold: Duration::from_secs(60),
68 experimental_min_refresh_duration: Duration::new(5, 0),
69 grpc_conn_timeout: Duration::from_secs(5),
70 experimental_grpc_max_retries: 3,
71 experimental_frontend_scan_timeout: Duration::from_secs(30),
72 experimental_max_filter_num_per_query: 20,
73 experimental_time_window_merge_threshold: 3,
74 read_preference: Default::default(),
75 frontend_tls: None,
76 }
77 }
78}