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