mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-10 23:26:53 +00:00
refactor: expose external ECStore owner symbols (#3748)
This commit is contained in:
@@ -13,8 +13,8 @@
|
||||
// limitations under the License.
|
||||
|
||||
use crate::{
|
||||
Event, NotificationError, ecstore_config, ecstore_global, ecstore_storage, registry::TargetRegistry,
|
||||
rule_engine::NotifyRuleEngine, runtime_facade::NotifyRuntimeFacade,
|
||||
Event, NotificationError, registry::TargetRegistry, resolve_notify_object_store_handle, rule_engine::NotifyRuleEngine,
|
||||
runtime_facade::NotifyRuntimeFacade,
|
||||
};
|
||||
use rustfs_config::notify::{
|
||||
NOTIFY_AMQP_SUB_SYS, NOTIFY_KAFKA_SUB_SYS, NOTIFY_MQTT_SUB_SYS, NOTIFY_MYSQL_SUB_SYS, NOTIFY_NATS_SUB_SYS,
|
||||
@@ -31,8 +31,6 @@ const LOG_SUBSYSTEM_CONFIG: &str = "config";
|
||||
const EVENT_NOTIFY_RUNTIME_LIFECYCLE: &str = "notify_runtime_lifecycle";
|
||||
const EVENT_NOTIFY_CONFIG_UPDATE: &str = "notify_config_update";
|
||||
|
||||
type NotifyStore = ecstore_storage::ECStore;
|
||||
|
||||
#[derive(Debug)]
|
||||
enum NotifyConfigStoreError {
|
||||
StorageNotAvailable,
|
||||
@@ -48,33 +46,21 @@ where
|
||||
return Err(NotifyConfigStoreError::StorageNotAvailable);
|
||||
};
|
||||
|
||||
let mut new_config = read_notify_server_config_without_migrate(store.clone()).await?;
|
||||
let mut new_config = crate::read_notify_server_config_without_migrate(store.clone())
|
||||
.await
|
||||
.map_err(NotifyConfigStoreError::Read)?;
|
||||
|
||||
if !modifier(&mut new_config) {
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
save_notify_server_config(store, &new_config).await?;
|
||||
crate::save_notify_server_config(store, &new_config)
|
||||
.await
|
||||
.map_err(NotifyConfigStoreError::Save)?;
|
||||
|
||||
Ok(Some(new_config))
|
||||
}
|
||||
|
||||
fn resolve_notify_object_store_handle() -> Option<Arc<NotifyStore>> {
|
||||
ecstore_global::resolve_object_store_handle()
|
||||
}
|
||||
|
||||
async fn read_notify_server_config_without_migrate(store: Arc<NotifyStore>) -> Result<Config, NotifyConfigStoreError> {
|
||||
ecstore_config::com::read_config_without_migrate(store)
|
||||
.await
|
||||
.map_err(|err| NotifyConfigStoreError::Read(err.to_string()))
|
||||
}
|
||||
|
||||
async fn save_notify_server_config(store: Arc<NotifyStore>, config: &Config) -> Result<(), NotifyConfigStoreError> {
|
||||
ecstore_config::com::save_server_config(store, config)
|
||||
.await
|
||||
.map_err(|err| NotifyConfigStoreError::Save(err.to_string()))
|
||||
}
|
||||
|
||||
pub(crate) fn notify_configuration_hint() -> String {
|
||||
let webhook_enable_primary = format!("{}_PRIMARY", rustfs_config::notify::ENV_NOTIFY_WEBHOOK_ENABLE);
|
||||
let webhook_endpoint_primary = format!("{}_PRIMARY", rustfs_config::notify::ENV_NOTIFY_WEBHOOK_ENDPOINT);
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
//! It supports sending events to various targets
|
||||
//! (like Webhook and MQTT) and includes features like event persistence and retry on failure.
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
mod bucket_config_manager;
|
||||
mod config_manager;
|
||||
mod error;
|
||||
@@ -37,9 +39,7 @@ mod runtime_view;
|
||||
mod services;
|
||||
mod status_view;
|
||||
|
||||
pub(crate) use rustfs_ecstore::api::config as ecstore_config;
|
||||
pub(crate) use rustfs_ecstore::api::global as ecstore_global;
|
||||
pub(crate) use rustfs_ecstore::api::storage as ecstore_storage;
|
||||
pub(crate) use rustfs_ecstore::api::storage::ECStore as NotifyStore;
|
||||
|
||||
pub use bucket_config_manager::NotifyBucketConfigManager;
|
||||
pub use config_manager::{NotifyConfigManager, runtime_target_id_for_subsystem};
|
||||
@@ -58,3 +58,24 @@ pub use runtime_facade::NotifyRuntimeFacade;
|
||||
pub use runtime_view::NotifyRuntimeView;
|
||||
pub use services::NotifyServices;
|
||||
pub use status_view::NotifyStatusView;
|
||||
|
||||
pub(crate) fn resolve_notify_object_store_handle() -> Option<Arc<NotifyStore>> {
|
||||
rustfs_ecstore::api::global::resolve_object_store_handle()
|
||||
}
|
||||
|
||||
pub(crate) async fn read_notify_server_config_without_migrate(
|
||||
store: Arc<NotifyStore>,
|
||||
) -> Result<rustfs_config::server_config::Config, String> {
|
||||
rustfs_ecstore::api::config::com::read_config_without_migrate(store)
|
||||
.await
|
||||
.map_err(|err| err.to_string())
|
||||
}
|
||||
|
||||
pub(crate) async fn save_notify_server_config(
|
||||
store: Arc<NotifyStore>,
|
||||
config: &rustfs_config::server_config::Config,
|
||||
) -> Result<(), String> {
|
||||
rustfs_ecstore::api::config::com::save_server_config(store, config)
|
||||
.await
|
||||
.map_err(|err| err.to_string())
|
||||
}
|
||||
|
||||
@@ -35,10 +35,13 @@
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use rustfs_ecstore::api::bucket as ecstore_bucket;
|
||||
use rustfs_ecstore::api::error as ecstore_error;
|
||||
use rustfs_ecstore::api::global as ecstore_global;
|
||||
use rustfs_ecstore::api::storage as ecstore_storage;
|
||||
use rustfs_ecstore::api::bucket::metadata::BucketMetadata as SwiftBucketMetadata;
|
||||
use rustfs_ecstore::api::bucket::metadata_sys::{
|
||||
get as get_swift_bucket_metadata_from_backend, set_bucket_metadata as set_swift_bucket_metadata_in_backend,
|
||||
};
|
||||
use rustfs_ecstore::api::error::Result as SwiftStorageResult;
|
||||
use rustfs_ecstore::api::global::resolve_object_store_handle as resolve_swift_object_store_handle;
|
||||
use rustfs_ecstore::api::storage::ECStore as SwiftStore;
|
||||
|
||||
pub mod account;
|
||||
pub mod acl;
|
||||
@@ -70,22 +73,15 @@ pub use router::{SwiftRoute, SwiftRouter};
|
||||
#[allow(unused_imports)]
|
||||
pub use types::{Container, Object, SwiftMetadata};
|
||||
|
||||
type SwiftBucketMetadata = ecstore_bucket::metadata::BucketMetadata;
|
||||
type SwiftStorageResult<T> = ecstore_error::Result<T>;
|
||||
type SwiftStore = ecstore_storage::ECStore;
|
||||
pub type SwiftGetObjectReader = <SwiftStore as rustfs_storage_api::ObjectIO>::GetObjectReader;
|
||||
pub type SwiftObjectInfo = <SwiftStore as rustfs_storage_api::ObjectOperations>::ObjectInfo;
|
||||
pub type SwiftObjectOptions = <SwiftStore as rustfs_storage_api::ObjectOperations>::ObjectOptions;
|
||||
pub type SwiftPutObjReader = <SwiftStore as rustfs_storage_api::ObjectIO>::PutObjectReader;
|
||||
|
||||
fn resolve_swift_object_store_handle() -> Option<Arc<SwiftStore>> {
|
||||
ecstore_global::resolve_object_store_handle()
|
||||
}
|
||||
|
||||
async fn get_swift_bucket_metadata(bucket: &str) -> SwiftStorageResult<Arc<SwiftBucketMetadata>> {
|
||||
ecstore_bucket::metadata_sys::get(bucket).await
|
||||
get_swift_bucket_metadata_from_backend(bucket).await
|
||||
}
|
||||
|
||||
async fn set_swift_bucket_metadata(bucket: String, metadata: SwiftBucketMetadata) -> SwiftStorageResult<()> {
|
||||
ecstore_bucket::metadata_sys::set_bucket_metadata(bucket, metadata).await
|
||||
set_swift_bucket_metadata_in_backend(bucket, metadata).await
|
||||
}
|
||||
|
||||
@@ -15,11 +15,10 @@
|
||||
use datafusion::{common::DataFusionError, sql::sqlparser::parser::ParserError};
|
||||
use snafu::{Backtrace, Location, Snafu};
|
||||
use std::fmt::Display;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub(crate) use rustfs_ecstore::api::error as ecstore_error;
|
||||
pub(crate) use rustfs_ecstore::api::global as ecstore_global;
|
||||
pub(crate) use rustfs_ecstore::api::set_disk as ecstore_set_disk;
|
||||
pub(crate) use rustfs_ecstore::api::storage as ecstore_storage;
|
||||
pub(crate) use rustfs_ecstore::api::error::StorageError as SelectStorageError;
|
||||
pub(crate) use rustfs_ecstore::api::storage::ECStore as SelectStore;
|
||||
|
||||
pub mod object_store;
|
||||
pub mod query;
|
||||
@@ -30,6 +29,28 @@ mod test;
|
||||
|
||||
pub type QueryResult<T> = Result<T, QueryError>;
|
||||
|
||||
pub(crate) type SelectGetObjectReader = <SelectStore as rustfs_storage_api::ObjectIO>::GetObjectReader;
|
||||
pub(crate) type SelectObjectInfo = <SelectStore as rustfs_storage_api::ObjectOperations>::ObjectInfo;
|
||||
pub(crate) type SelectObjectOptions = <SelectStore as rustfs_storage_api::ObjectOperations>::ObjectOptions;
|
||||
|
||||
pub(crate) const SELECT_DEFAULT_READ_BUFFER_SIZE: usize = rustfs_ecstore::api::set_disk::DEFAULT_READ_BUFFER_SIZE;
|
||||
|
||||
pub(crate) fn resolve_select_object_store_handle() -> Option<Arc<SelectStore>> {
|
||||
rustfs_ecstore::api::global::resolve_object_store_handle()
|
||||
}
|
||||
|
||||
pub(crate) fn select_is_err_bucket_not_found(err: &SelectStorageError) -> bool {
|
||||
rustfs_ecstore::api::error::is_err_bucket_not_found(err)
|
||||
}
|
||||
|
||||
pub(crate) fn select_is_err_object_not_found(err: &SelectStorageError) -> bool {
|
||||
rustfs_ecstore::api::error::is_err_object_not_found(err)
|
||||
}
|
||||
|
||||
pub(crate) fn select_is_err_version_not_found(err: &SelectStorageError) -> bool {
|
||||
rustfs_ecstore::api::error::is_err_version_not_found(err)
|
||||
}
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
pub enum QueryError {
|
||||
|
||||
@@ -12,7 +12,11 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use crate::{ecstore_error, ecstore_global, ecstore_set_disk, ecstore_storage};
|
||||
use crate::{
|
||||
SELECT_DEFAULT_READ_BUFFER_SIZE, SelectGetObjectReader, SelectObjectInfo, SelectObjectOptions, SelectStorageError,
|
||||
SelectStore, resolve_select_object_store_handle, select_is_err_bucket_not_found, select_is_err_object_not_found,
|
||||
select_is_err_version_not_found,
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
use bytes::Bytes;
|
||||
use chrono::Utc;
|
||||
@@ -45,34 +49,10 @@ use tokio::io::{AsyncRead, ReadBuf};
|
||||
use tokio_util::io::ReaderStream;
|
||||
use transform_stream::AsyncTryStream;
|
||||
|
||||
type SelectStorageError = ecstore_error::StorageError;
|
||||
type SelectStore = ecstore_storage::ECStore;
|
||||
type SelectGetObjectReader = <SelectStore as rustfs_storage_api::ObjectIO>::GetObjectReader;
|
||||
type SelectObjectInfo = <SelectStore as rustfs_storage_api::ObjectOperations>::ObjectInfo;
|
||||
type SelectObjectOptions = <SelectStore as rustfs_storage_api::ObjectOperations>::ObjectOptions;
|
||||
|
||||
const SELECT_DEFAULT_READ_BUFFER_SIZE: usize = ecstore_set_disk::DEFAULT_READ_BUFFER_SIZE;
|
||||
|
||||
fn select_default_read_buffer_size_u64() -> u64 {
|
||||
u64::try_from(SELECT_DEFAULT_READ_BUFFER_SIZE).unwrap_or(u64::MAX)
|
||||
}
|
||||
|
||||
fn resolve_select_object_store_handle() -> Option<Arc<SelectStore>> {
|
||||
ecstore_global::resolve_object_store_handle()
|
||||
}
|
||||
|
||||
fn select_is_err_bucket_not_found(err: &SelectStorageError) -> bool {
|
||||
ecstore_error::is_err_bucket_not_found(err)
|
||||
}
|
||||
|
||||
fn select_is_err_object_not_found(err: &SelectStorageError) -> bool {
|
||||
ecstore_error::is_err_object_not_found(err)
|
||||
}
|
||||
|
||||
fn select_is_err_version_not_found(err: &SelectStorageError) -> bool {
|
||||
ecstore_error::is_err_version_not_found(err)
|
||||
}
|
||||
|
||||
/// Maximum allowed object size for JSON DOCUMENT mode.
|
||||
///
|
||||
/// JSON DOCUMENT format requires loading the entire file into memory for DOM
|
||||
|
||||
Reference in New Issue
Block a user