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_limiter;
54mod row_writer;
55pub mod server;
56pub mod tls;
57
58/// Cached SQL and logical plan for database interfaces
59#[derive(Clone)]
60pub struct SqlPlan {
61    query: String,
62    // Store the parsed statement to determine if it is a query and whether to track it.
63    statement: Option<Statement>,
64    plan: Option<LogicalPlan>,
65    schema: Option<Schema>,
66}
67
68/// Install the ring crypto provider for rustls process-wide. see:
69///
70///  https://docs.rs/rustls/latest/rustls/crypto/struct.CryptoProvider.html#using-the-per-process-default-cryptoprovider
71///
72/// for more information.
73pub fn install_ring_crypto_provider() -> Result<(), String> {
74    rustls::crypto::CryptoProvider::install_default(rustls::crypto::ring::default_provider())
75        .map_err(|ret| {
76            format!(
77                "CryptoProvider already installed as: {:?}, but providing {:?}",
78                rustls::crypto::CryptoProvider::get_default(),
79                ret
80            )
81        })
82}