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
19pub(crate) mod engine;
20pub(crate) mod frontend_client;
21mod state;
22mod task;
23mod time_window;
24mod utils;
25
26/// TODO(discord9): make those constants configurable
27/// The default batching engine query timeout is 10 minutes
28pub const DEFAULT_BATCHING_ENGINE_QUERY_TIMEOUT: Duration = Duration::from_secs(10 * 60);
29
30/// will output a warn log for any query that runs for more that 1 minutes, and also every 1 minutes when that query is still running
31pub const SLOW_QUERY_THRESHOLD: Duration = Duration::from_secs(60);
32
33/// The minimum duration between two queries execution by batching mode task
34pub const MIN_REFRESH_DURATION: Duration = Duration::new(5, 0);
35
36/// Grpc connection timeout
37const GRPC_CONN_TIMEOUT: Duration = Duration::from_secs(5);
38
39/// Grpc max retry number
40const GRPC_MAX_RETRIES: u32 = 3;
41
42/// Flow wait for available frontend timeout,
43/// if failed to find available frontend after FRONTEND_SCAN_TIMEOUT elapsed, return error
44/// which should prevent flownode from starting
45pub const FRONTEND_SCAN_TIMEOUT: Duration = Duration::from_secs(30);
46
47/// Frontend activity timeout
48/// if frontend is down(not sending heartbeat) for more than FRONTEND_ACTIVITY_TIMEOUT, it will be removed from the list that flownode use to connect
49pub const FRONTEND_ACTIVITY_TIMEOUT: Duration = Duration::from_secs(60);