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    pub(crate) query: String,
61    pub(crate) statement: Option<Statement>,
62    pub(crate) plan: Option<LogicalPlan>,
63    pub(crate) schema: Option<Schema>,
64}
65
66/// Install the ring crypto provider for rustls process-wide. see:
67///
68///  https://docs.rs/rustls/latest/rustls/crypto/struct.CryptoProvider.html#using-the-per-process-default-cryptoprovider
69///
70/// for more information.
71pub fn install_ring_crypto_provider() -> Result<(), String> {
72    rustls::crypto::CryptoProvider::install_default(rustls::crypto::ring::default_provider())
73        .map_err(|ret| {
74            format!(
75                "CryptoProvider already installed as: {:?}, but providing {:?}",
76                rustls::crypto::CryptoProvider::get_default(),
77                ret
78            )
79        })
80}