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 mod prom_store;
46pub mod prometheus;
47pub mod prometheus_handler;
48pub mod query_handler;
49pub mod repeated_field;
50pub mod request_memory_limiter;
51pub mod request_memory_metrics;
52mod row_writer;
53pub mod server;
54pub mod tls;
55
56/// Cached SQL and logical plan for database interfaces
57#[derive(Clone, Debug)]
58pub struct SqlPlan {
59    query: String,
60    // Store the parsed statement to determine if it is a query and whether to track it.
61    statement: Option<Statement>,
62    plan: Option<LogicalPlan>,
63    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}