Skip to main content

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