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(if_let_guard)]
19#![feature(box_patterns)]
20
21use datafusion_expr::LogicalPlan;
22use datatypes::schema::Schema;
23use sql::statements::statement::Statement;
24// Re-export for use in add_service! macro
25#[doc(hidden)]
26pub use tower;
27
28pub mod addrs;
29pub mod configurator;
30pub(crate) mod elasticsearch;
31pub mod error;
32pub mod grpc;
33pub mod heartbeat_options;
34mod hint_headers;
35pub mod http;
36pub mod influxdb;
37pub mod interceptor;
38pub mod metrics;
39pub mod metrics_handler;
40pub mod mysql;
41pub mod opentsdb;
42pub mod otel_arrow;
43pub mod otlp;
44mod pipeline;
45pub mod postgres;
46pub mod prom_row_builder;
47pub mod prom_store;
48pub mod prometheus;
49pub mod prometheus_handler;
50pub mod proto;
51pub mod query_handler;
52pub mod repeated_field;
53pub mod request_memory_limiter;
54pub mod request_memory_metrics;
55mod row_writer;
56pub mod server;
57pub mod tls;
58
59/// Cached SQL and logical plan for database interfaces
60#[derive(Clone, Debug)]
61pub struct SqlPlan {
62    query: String,
63    // Store the parsed statement to determine if it is a query and whether to track it.
64    statement: Option<Statement>,
65    plan: Option<LogicalPlan>,
66    schema: Option<Schema>,
67}
68
69/// Install the ring 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_ring_crypto_provider() -> Result<(), String> {
75    rustls::crypto::CryptoProvider::install_default(rustls::crypto::ring::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}