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
15#![feature(assert_matches)]
16#![feature(try_blocks)]
17#![feature(exclusive_wrapper)]
18#![feature(let_chains)]
19#![feature(if_let_guard)]
20
21use datafusion_expr::LogicalPlan;
22use datatypes::schema::Schema;
23use sql::statements::statement::Statement;
24
25pub mod addrs;
26pub mod configurator;
27pub(crate) mod elasticsearch;
28pub mod error;
29pub mod export_metrics;
30pub mod grpc;
31pub mod heartbeat_options;
32mod hint_headers;
33pub mod http;
34pub mod influxdb;
35pub mod interceptor;
36pub mod metrics;
37pub mod metrics_handler;
38pub mod mysql;
39pub mod opentsdb;
40pub mod otel_arrow;
41pub mod otlp;
42mod pipeline;
43pub mod postgres;
44pub mod prom_row_builder;
45pub mod prom_store;
46pub mod prometheus;
47pub mod prometheus_handler;
48pub mod proto;
49pub mod query_handler;
50pub mod repeated_field;
51mod row_writer;
52pub mod server;
53pub mod tls;
54
55/// Cached SQL and logical plan for database interfaces
56#[derive(Clone)]
57pub struct SqlPlan {
58    query: String,
59    // Store the parsed statement to determine if it is a query and whether to track it.
60    statement: Option<Statement>,
61    plan: Option<LogicalPlan>,
62    schema: Option<Schema>,
63}
64
65/// Install the ring crypto provider for rustls process-wide. see:
66///
67///  https://docs.rs/rustls/latest/rustls/crypto/struct.CryptoProvider.html#using-the-per-process-default-cryptoprovider
68///
69/// for more information.
70pub fn install_ring_crypto_provider() -> Result<(), String> {
71    rustls::crypto::CryptoProvider::install_default(rustls::crypto::ring::default_provider())
72        .map_err(|ret| {
73            format!(
74                "CryptoProvider already installed as: {:?}, but providing {:?}",
75                rustls::crypto::CryptoProvider::get_default(),
76                ret
77            )
78        })
79}