Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISSUE-5019: re-reorganization the common crates #5233

Merged
merged 1 commit into from
May 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
53 changes: 9 additions & 44 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@ members = [
"common/base",
"common/building",
"common/cache",
"common/containers",
"common/contexts",
"common/datablocks",
"common/datavalues",
"common/exception",
"common/grpc",
"common/functions",
"common/infallible",
"common/io",
"common/macros",
"common/management",
"common/mem-allocator",
"common/planners",
"common/proto-conv",
"common/protos",
Expand All @@ -25,7 +22,6 @@ members = [
"common/meta/raft-store",
"common/meta/sled-store",
"common/meta/types",
"common/range-map",
"common/streams",
"common/codegen",
"common/tracing",
Expand Down
2 changes: 1 addition & 1 deletion common/ast/tests/it/udfs/udf_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

use common_ast::udfs::*;
use common_base::tokio;
use common_base::base::tokio;
use common_exception::Result;
use pretty_assertions::assert_eq;
use sqlparser::ast::Expr;
Expand Down
2 changes: 1 addition & 1 deletion common/ast/tests/it/udfs/udf_transformer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use async_trait::async_trait;
use common_ast::udfs::*;
use common_base::tokio;
use common_base::base::tokio;
use common_exception::ErrorCode;
use common_exception::Result;
use pretty_assertions::assert_eq;
Expand Down
15 changes: 15 additions & 0 deletions common/base/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ test = false

[features]
tracing = ["tokio/tracing"]
memory-profiling = [
"tikv-jemalloc-ctl",
"libc",
"tikv-jemalloc-sys/stats",
"tikv-jemalloc-sys/profiling",
"tikv-jemalloc-sys/unprefixed_malloc_on_supported_platforms",
]

[dependencies] # In alphabetical order
# Workspace dependencies
Expand All @@ -25,6 +32,8 @@ async-trait = "0.1.53"
ctrlc = { version = "3.2.1", features = ["termination"] }
futures = "0.3.21"
hyper = "0.14.18"
libc = { version = "0.2", optional = true }
parking_lot = "0.12.0"
poem = { version = "=1.3.16", features = ["rustls"] }
serde = { version = "1.0.136", features = ["derive"] }
serde_json = { version = "1.0.79", default-features = false, features = ["raw_value"] }
Expand All @@ -35,6 +44,12 @@ pprof = { git = "https://github.com/tikv/pprof-rs", rev = "666d9e2", features =
"protobuf-codec",
"protobuf",
] }
tikv-jemalloc-ctl = { version = "0.4", optional = true }
tikv-jemalloc-sys = { version = "0.4.3" }
tokio = { version = "1.17.0", features = ["full"] }
toml = { version = "0.5.8", default-features = false }
uuid = { version = "0.8.2", features = ["serde", "v4"] }

[dev-dependencies]
anyhow = "1.0.56"
common-macros = { path = "../macros" }
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ use poem::listener::Listener;
use poem::listener::RustlsConfig;
use poem::listener::TcpListener;
use poem::Endpoint;
use tokio::sync::broadcast;
use tokio::sync::oneshot;
use tokio::task::JoinHandle;

use crate::tokio::sync::broadcast;

pub struct HttpShutdownHandler {
service_name: String,
join_handle: Option<JoinHandle<std::io::Result<()>>>,
Expand Down
54 changes: 54 additions & 0 deletions common/base/src/base/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright 2021 Datafuse Labs.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

mod format;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to add the copyright :D

mod http_shutdown_handlers;
mod net;
mod profiling;
mod progress;
mod runtime;
mod runtime_tracker;
mod shutdown_signal;
mod stop_handle;
mod stoppable;
mod string_func;
mod thread;
mod uniq_id;

pub use format::Format;
pub use http_shutdown_handlers::HttpShutdownHandler;
pub use net::get_free_tcp_port;
pub use net::get_free_udp_port;
pub use profiling::Profiling;
pub use progress::Progress;
pub use progress::ProgressValues;
pub use runtime::Dropper;
pub use runtime::Runtime;
pub use runtime::TrySpawn;
pub use runtime_tracker::RuntimeTracker;
pub use runtime_tracker::ThreadTracker;
pub use shutdown_signal::signal_stream;
pub use shutdown_signal::DummySignalStream;
pub use shutdown_signal::SignalStream;
pub use shutdown_signal::SignalType;
pub use stop_handle::StopHandle;
pub use stoppable::Stoppable;
pub use string_func::escape_for_key;
pub use string_func::mask_string;
pub use string_func::unescape_for_key;
pub use thread::Thread;
pub use tokio;
pub use uniq_id::GlobalSequence;
pub use uniq_id::GlobalUniqName;
pub use uuid;
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use tokio::runtime::Handle;
use tokio::sync::oneshot;
use tokio::task::JoinHandle;

use crate::runtime_tracker::RuntimeTracker;
use super::runtime_tracker::RuntimeTracker;

/// Methods to spawn tasks.
pub trait TrySpawn {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use common_tracing::tracing;
use futures::Future;
use tokio::sync::broadcast;

use crate::Stoppable;
use super::Stoppable;

/// Handle a group of `Stoppable` tasks.
/// When a user press ctrl-c, it calls the `stop()` method on every task to close them.
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use std::thread::Builder;
use std::thread::JoinHandle;

use crate::runtime_tracker::ThreadTracker;
use super::runtime_tracker::ThreadTracker;

pub struct Thread;

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ use std::sync::Mutex;
use std::time::Duration;

use async_trait::async_trait;
use common_base::tokio;
use common_base::tokio::time::sleep;
use common_tracing::tracing;

use crate::base::tokio;
use crate::base::tokio::time::sleep;

pub type PoolItem<T> = Arc<tokio::sync::Mutex<Option<T>>>;

/// To build or check an item.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub use rwlock_upgrade_read::RwLockUpgradableReadGuard;
#[macro_export]
macro_rules! exit_scope {
($x:block) => {
use common_infallible::ExitGuard;
use common_base::infallible::ExitGuard;
let _exit_guard = ExitGuard::create(move || $x);
};
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use parking_lot::RwLock as ParkingRwLock;
use parking_lot::RwLockReadGuard;
use parking_lot::RwLockWriteGuard;

use crate::RwLockUpgradableReadGuard;
use super::RwLockUpgradableReadGuard;

/// A simple wrapper around the lock() function of a std::sync::RwLock
/// The only difference is that you don't need to call unwrap() on it.
Expand Down
Loading