servers/lib.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
15use datafusion_expr::LogicalPlan;
16use sql::statements::statement::Statement;
17// Re-export for use in add_service! macro
18#[doc(hidden)]
19pub use tower;
20
21pub mod addrs;
22pub mod batcher;
23pub mod configurator;
24pub(crate) mod elasticsearch;
25pub mod error;
26pub mod grpc;
27
28mod hint_headers;
29pub mod http;
30pub mod influxdb;
31pub mod interceptor;
32pub mod metrics;
33pub mod metrics_handler;
34pub mod mysql;
35pub mod opentsdb;
36pub mod otel_arrow;
37pub mod otlp;
38mod pipeline;
39pub mod postgres;
40pub mod prom_remote_write;
41pub(crate) mod prom_row_builder;
42pub mod prom_store;
43pub mod prometheus;
44pub mod prometheus_handler;
45pub mod query_handler;
46pub mod repeated_field;
47pub mod request_memory_limiter;
48pub mod request_memory_metrics;
49mod row_writer;
50pub mod semantic;
51pub mod server;
52pub mod tls;
53
54/// Cached sql plan or statement for database interfaces
55#[derive(Clone, Debug)]
56pub enum SqlPlan {
57 /// Empty Query
58 Empty,
59 /// Hardcoded SQL shortcuts
60 Shortcut(String),
61 /// Datafusion parsed execution plan with the original statement
62 Plan(LogicalPlan, Statement),
63 /// Parsed statement when execution is not managed by datafusion
64 /// eg. CREATE TABLE
65 /// The String is the original query string to avoid AST round-trip issues
66 Statement(Statement, String),
67}
68
69/// Install the default crypto provider for rustls process-wide. see:
70///
71/// https://docs.rs/rustls/latest/rustls/crypto/struct.CryptoProvider.html#using-the-per-process-default-cryptoprovider
72///
73/// for more information.
74pub fn install_default_crypto_provider() -> Result<(), String> {
75 rustls::crypto::CryptoProvider::install_default(rustls::crypto::aws_lc_rs::default_provider())
76 .map_err(|ret| {
77 format!(
78 "CryptoProvider already installed as: {:?}, but providing {:?}",
79 rustls::crypto::CryptoProvider::get_default(),
80 ret
81 )
82 })
83}