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