mirror of
https://github.com/rustfs/rustfs.git
synced 2026-07-27 16:48:58 +00:00
init bucketmeta struct
This commit is contained in:
@@ -1,69 +0,0 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::name::Name;
|
||||
|
||||
// 定义common结构体
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct Common {
|
||||
pub id: String,
|
||||
pub filter: S3Key,
|
||||
pub events: Vec<Name>,
|
||||
}
|
||||
|
||||
// 定义Queue结构体
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct Queue {
|
||||
pub common: Common,
|
||||
pub arn: ARN,
|
||||
}
|
||||
|
||||
// 定义ARN结构体
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct ARN {
|
||||
pub target_id: TargetID,
|
||||
pub region: String,
|
||||
}
|
||||
|
||||
// 定义TargetID结构体
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct TargetID {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
// 定义FilterRule结构体
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct FilterRule {
|
||||
pub name: String,
|
||||
pub value: String,
|
||||
}
|
||||
|
||||
// 定义FilterRuleList结构体
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct FilterRuleList {
|
||||
pub rules: Vec<FilterRule>,
|
||||
}
|
||||
|
||||
// 定义S3Key结构体
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct S3Key {
|
||||
pub rule_list: FilterRuleList,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct Lambda {
|
||||
arn: String,
|
||||
}
|
||||
|
||||
// 定义Topic结构体
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct Topic {
|
||||
arn: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct Config {
|
||||
queue_list: Vec<Queue>,
|
||||
lambda_list: Vec<Lambda>,
|
||||
topic_list: Vec<Topic>,
|
||||
}
|
||||
@@ -1,2 +1,71 @@
|
||||
pub(crate) mod config;
|
||||
mod name;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use name::Name;
|
||||
|
||||
// 定义common结构体
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct Common {
|
||||
pub id: String,
|
||||
pub filter: S3Key,
|
||||
pub events: Vec<Name>,
|
||||
}
|
||||
|
||||
// 定义Queue结构体
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct Queue {
|
||||
pub common: Common,
|
||||
pub arn: ARN,
|
||||
}
|
||||
|
||||
// 定义ARN结构体
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct ARN {
|
||||
pub target_id: TargetID,
|
||||
pub region: String,
|
||||
}
|
||||
|
||||
// 定义TargetID结构体
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct TargetID {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
// 定义FilterRule结构体
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct FilterRule {
|
||||
pub name: String,
|
||||
pub value: String,
|
||||
}
|
||||
|
||||
// 定义FilterRuleList结构体
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct FilterRuleList {
|
||||
pub rules: Vec<FilterRule>,
|
||||
}
|
||||
|
||||
// 定义S3Key结构体
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct S3Key {
|
||||
pub rule_list: FilterRuleList,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct Lambda {
|
||||
arn: String,
|
||||
}
|
||||
|
||||
// 定义Topic结构体
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct Topic {
|
||||
arn: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct Config {
|
||||
queue_list: Vec<Queue>,
|
||||
lambda_list: Vec<Lambda>,
|
||||
topic_list: Vec<Topic>,
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::{prefix::Prefix, tag::Tag};
|
||||
|
||||
#[derive(Debug)]
|
||||
use serde::{Deserialize, Serialize};
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct And {
|
||||
pub object_size_greater_than: i64,
|
||||
pub object_size_less_than: i64,
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#[derive(Debug)]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct DelMarkerExpiration {
|
||||
pub days: usize,
|
||||
}
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use time::OffsetDateTime;
|
||||
|
||||
// ExpirationDays is a type alias to unmarshal Days in Expiration
|
||||
pub type ExpirationDays = usize;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct ExpirationDate(OffsetDateTime);
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct ExpirationDate(Option<OffsetDateTime>);
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct ExpireDeleteMarker {
|
||||
pub marker: Boolean,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct Boolean {
|
||||
pub val: bool,
|
||||
pub set: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct Expiration {
|
||||
pub days: Option<ExpirationDays>,
|
||||
pub date: Option<ExpirationDate>,
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
use super::{and::And, prefix::Prefix, tag::Tag};
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Debug)]
|
||||
use super::{and::And, prefix::Prefix, tag::Tag};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct Filter {
|
||||
pub set: bool,
|
||||
|
||||
@@ -16,5 +19,5 @@ pub struct Filter {
|
||||
pub tag_set: bool,
|
||||
|
||||
// 使用HashMap存储缓存的标签
|
||||
pub cached_tags: std::collections::HashMap<String, String>,
|
||||
pub cached_tags: HashMap<String, String>,
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use super::rule::Rule;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use time::OffsetDateTime;
|
||||
|
||||
use super::rule::Rule;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct Lifecycle {
|
||||
pub rules: Vec<Rule>,
|
||||
pub expiry_updated_at: Option<OffsetDateTime>,
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
use super::{expiration::ExpirationDays, transition::TransitionDays};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct NoncurrentVersionExpiration {
|
||||
pub noncurrent_days: ExpirationDays,
|
||||
pub newer_noncurrent_versions: usize,
|
||||
set: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct NoncurrentVersionTransition {
|
||||
pub noncurrent_days: TransitionDays,
|
||||
pub storage_class: String,
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#[derive(Debug)]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct Prefix {
|
||||
pub val: String,
|
||||
pub set: bool,
|
||||
|
||||
@@ -6,14 +6,16 @@ use super::{
|
||||
prefix::Prefix,
|
||||
transition::Transition,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub enum Status {
|
||||
#[default]
|
||||
Enabled,
|
||||
Disabled,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct Rule {
|
||||
pub id: String,
|
||||
pub status: Status,
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#[derive(Debug)]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct Tag {
|
||||
pub key: String,
|
||||
pub value: String,
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use time::OffsetDateTime;
|
||||
|
||||
pub type TransitionDays = usize;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct TransitionDate(OffsetDateTime);
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct TransitionDate(Option<OffsetDateTime>);
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct Transition {
|
||||
pub days: Option<TransitionDays>,
|
||||
pub date: Option<TransitionDate>,
|
||||
|
||||
@@ -1,11 +1,23 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use rmp_serde::Serializer;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use time::OffsetDateTime;
|
||||
|
||||
use super::{
|
||||
encryption::BucketSSEConfig, event, lifecycle::lifecycle::Lifecycle, objectlock, policy::bucket_policy::BucketPolicy,
|
||||
quota::BucketQuota, replication, tags::Tags, versioning::Versioning,
|
||||
quota::BucketQuota, replication, tags::Tags, target::BucketTargets, versioning::Versioning,
|
||||
};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
use crate::error::Result;
|
||||
|
||||
use crate::disk::BUCKET_META_PREFIX;
|
||||
|
||||
pub const BUCKET_METADATA_FILE: &str = ".metadata.bin";
|
||||
pub const BUCKET_METADATA_FORMAT: u16 = 1;
|
||||
pub const BUCKET_METADATA_VERSION: u16 = 1;
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct BucketMetadata {
|
||||
format: u16,
|
||||
version: u16,
|
||||
@@ -37,21 +49,45 @@ pub struct BucketMetadata {
|
||||
pub bucket_targets_config_meta_updated_at: Option<OffsetDateTime>,
|
||||
|
||||
// 新增UpdatedAt字段
|
||||
new_field_updated_at: Option<OffsetDateTime>,
|
||||
pub new_field_updated_at: Option<OffsetDateTime>,
|
||||
|
||||
// 私有字段,需要原子更新
|
||||
policy_config: Option<BucketPolicy>, // 假设Policy是一个已经定义好的结构体
|
||||
notification_config: Option<event::config::Config>,
|
||||
lifecycle_config: Option<Lifecycle>,
|
||||
object_lock_config: Option<objectlock::Config>,
|
||||
versioning_config: Option<Versioning>,
|
||||
sse_config: Option<BucketSSEConfig>,
|
||||
tagging_config: Option<Tags>,
|
||||
quota_config: Option<BucketQuota>,
|
||||
replication_config: Option<replication::Config>,
|
||||
bucket_target_config: Option<BucketTargets>,
|
||||
bucket_target_config_meta: Option<std::collections::HashMap<String, String>>,
|
||||
pub policy_config: Option<BucketPolicy>, // 假设Policy是一个已经定义好的结构体
|
||||
pub notification_config: Option<event::Config>,
|
||||
pub lifecycle_config: Option<Lifecycle>,
|
||||
pub object_lock_config: Option<objectlock::Config>,
|
||||
pub versioning_config: Option<Versioning>,
|
||||
pub sse_config: Option<BucketSSEConfig>,
|
||||
pub tagging_config: Option<Tags>,
|
||||
pub quota_config: Option<BucketQuota>,
|
||||
pub replication_config: Option<replication::Config>,
|
||||
pub bucket_target_config: Option<BucketTargets>,
|
||||
pub bucket_target_config_meta: Option<HashMap<String, String>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
struct BucketTargets;
|
||||
impl BucketMetadata {
|
||||
pub fn new(name: &str) -> Self {
|
||||
BucketMetadata {
|
||||
format: BUCKET_METADATA_FORMAT,
|
||||
version: BUCKET_METADATA_VERSION,
|
||||
name: name.to_string(),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn save_file_path(&self) -> String {
|
||||
format!("{}/{}/{}", BUCKET_META_PREFIX, self.name.as_str(), BUCKET_METADATA_FILE)
|
||||
}
|
||||
|
||||
fn msg_size(&self) -> usize {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub fn marshal_msg(&self) -> Result<Vec<u8>> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub fn unmarshal(_buf: &[u8]) -> Result<Self> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,3 +9,5 @@ mod replication;
|
||||
mod tags;
|
||||
mod target;
|
||||
mod versioning;
|
||||
|
||||
pub use metadata::BucketMetadata;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Default, PartialEq, Eq, Hash)]
|
||||
pub enum RetMode {
|
||||
#[default]
|
||||
Govenance,
|
||||
Compliance,
|
||||
}
|
||||
@@ -17,19 +20,19 @@ impl std::str::FromStr for RetMode {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct DefaultRetention {
|
||||
pub mode: RetMode,
|
||||
pub days: Option<usize>,
|
||||
pub years: Option<usize>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct Rule {
|
||||
pub default_retention: DefaultRetention,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct Config {
|
||||
pub object_lock_enabled: String,
|
||||
pub rule: Option<Rule>,
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
use std::{collections::HashSet, default};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashSet;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct ActionSet(HashSet<Action>);
|
||||
|
||||
impl ActionSet {}
|
||||
|
||||
// 定义Action枚举类型
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Default)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize, Default, Hash)]
|
||||
pub enum Action {
|
||||
AbortMultipartUpload,
|
||||
CreateBucket,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
|
||||
use super::{
|
||||
@@ -8,7 +9,7 @@ use super::{
|
||||
resource::ResourceSet,
|
||||
};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct BucketPolicyArgs {
|
||||
account_name: String,
|
||||
groups: Vec<String>,
|
||||
@@ -19,7 +20,7 @@ pub struct BucketPolicyArgs {
|
||||
object_name: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct BPStatement {
|
||||
sid: String,
|
||||
effect: Effect,
|
||||
@@ -31,7 +32,7 @@ pub struct BPStatement {
|
||||
conditions: Option<Functions>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct BucketPolicy {
|
||||
pub id: String,
|
||||
pub version: String,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use super::name::Name;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
fmt::{Debug, Display},
|
||||
fmt::Debug,
|
||||
};
|
||||
|
||||
use super::name::Name;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Key {
|
||||
name: String,
|
||||
@@ -15,7 +15,7 @@ pub struct Key {
|
||||
pub type ValueSet = HashSet<String>;
|
||||
|
||||
// 定义Function trait
|
||||
pub trait Function {
|
||||
pub trait FunctionApi {
|
||||
// evaluate方法
|
||||
fn evaluate(&self, values: &HashMap<Key, ValueSet>) -> bool;
|
||||
|
||||
@@ -32,34 +32,24 @@ pub trait Function {
|
||||
fn to_map(&self) -> HashMap<Key, ValueSet>;
|
||||
|
||||
// clone方法
|
||||
fn clone(&self) -> Box<dyn Function>;
|
||||
fn clone(&self) -> Box<Function>;
|
||||
}
|
||||
|
||||
impl Display for dyn Function {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{:?}", self.to_string())
|
||||
}
|
||||
}
|
||||
// impl Debug for dyn Function {
|
||||
// fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
// write!(f, "{:?}", self.to_string())
|
||||
// }
|
||||
// }
|
||||
|
||||
impl Debug for dyn Function {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{:?}", self.to_string())
|
||||
}
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
enum Function {
|
||||
#[default]
|
||||
Test,
|
||||
}
|
||||
|
||||
// 定义Functions类型
|
||||
pub struct Functions(Vec<Box<dyn Function>>);
|
||||
|
||||
impl Display for Functions {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "[")?;
|
||||
for v in self.0.iter() {
|
||||
write!(f, "{:?}", v.to_string())?;
|
||||
}
|
||||
|
||||
write!(f, "]")
|
||||
}
|
||||
}
|
||||
#[derive(Deserialize, Serialize, Default)]
|
||||
pub struct Functions(Vec<Function>);
|
||||
|
||||
impl Debug for Functions {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::str::FromStr;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize, Default)]
|
||||
pub enum Effect {
|
||||
#[default]
|
||||
Allow,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashSet;
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
|
||||
pub struct Principal {
|
||||
aws: HashSet<String>,
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
use std::{collections::HashSet, default};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashSet;
|
||||
|
||||
// 定义ResourceARNType枚举类型
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Deserialize, Serialize, Default)]
|
||||
pub enum ResourceARNType {
|
||||
#[default]
|
||||
UnknownARN,
|
||||
@@ -14,11 +15,11 @@ const RESOURCE_ARN_PREFIX: &str = "arn:aws:s3:::";
|
||||
const RESOURCE_ARN_KMS_PREFIX: &str = "arn:rustfs:kms::::";
|
||||
|
||||
// 定义Resource结构体
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default, PartialEq, Eq, Hash)]
|
||||
pub struct Resource {
|
||||
pattern: String,
|
||||
r#type: ResourceARNType,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct ResourceSet(HashSet<Resource>);
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
use super::tag::Tag;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
// 定义And结构体
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct And {
|
||||
prefix: Option<String>,
|
||||
tags: Option<Vec<Tag>>,
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
use super::and::And;
|
||||
use super::tag::Tag;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct Filter {
|
||||
prefix: String,
|
||||
and: And,
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
use rule::Rule;
|
||||
|
||||
mod and;
|
||||
mod filter;
|
||||
mod rule;
|
||||
mod tag;
|
||||
|
||||
#[derive(Debug)]
|
||||
use rule::Rule;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct Config {
|
||||
rules: Vec<Rule>,
|
||||
role_arn: String,
|
||||
|
||||
@@ -1,27 +1,29 @@
|
||||
use super::filter::Filter;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub enum Status {
|
||||
#[default]
|
||||
Enabled,
|
||||
Disabled,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct DeleteMarkerReplication {
|
||||
pub status: Status,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct DeleteReplication {
|
||||
pub status: Status,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct ExistingObjectReplication {
|
||||
pub status: Status,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct Destination {
|
||||
pub bucket: String,
|
||||
pub storage_class: String,
|
||||
@@ -29,18 +31,18 @@ pub struct Destination {
|
||||
}
|
||||
|
||||
// 定义ReplicaModifications结构体
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct ReplicaModifications {
|
||||
status: Status,
|
||||
}
|
||||
|
||||
// 定义SourceSelectionCriteria结构体
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct SourceSelectionCriteria {
|
||||
replica_modifications: ReplicaModifications,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct Rule {
|
||||
pub id: String,
|
||||
pub status: Status,
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#[derive(Debug)]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct Tag {
|
||||
pub key: Option<String>,
|
||||
pub value: Option<String>,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::time::Duration;
|
||||
use time::OffsetDateTime;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct Credentials {
|
||||
access_key: String,
|
||||
secret_key: String,
|
||||
@@ -8,93 +10,70 @@ pub struct Credentials {
|
||||
expiration: Option<OffsetDateTime>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub enum ServiceType {
|
||||
#[default]
|
||||
Replication,
|
||||
}
|
||||
|
||||
// pub struct LatencyStat {
|
||||
// curr: Duration, // 当前延迟
|
||||
// avg: Duration, // 平均延迟
|
||||
// max: Duration, // 最大延迟
|
||||
// }
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct LatencyStat {
|
||||
curr: Duration, // 当前延迟
|
||||
avg: Duration, // 平均延迟
|
||||
max: Duration, // 最大延迟
|
||||
}
|
||||
|
||||
// #[derive(Serialize, Deserialize, Debug)]
|
||||
// pub struct LatencyStat {
|
||||
// curr: Duration,
|
||||
// avg: Duration,
|
||||
// max: Duration,
|
||||
// }
|
||||
// 定义BucketTarget结构体
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct BucketTarget {
|
||||
source_bucket: String,
|
||||
|
||||
// // 定义BucketTarget结构体
|
||||
// #[derive(Serialize, Deserialize, Debug)]
|
||||
// pub struct BucketTarget {
|
||||
// #[serde(rename = "sourcebucket")]
|
||||
// source_bucket: String,
|
||||
endpoint: String,
|
||||
|
||||
// #[serde(rename = "endpoint")]
|
||||
// endpoint: String,
|
||||
credentials: Option<Credentials>,
|
||||
|
||||
// #[serde(rename = "credentials")]
|
||||
// credentials: Option<Credentials>,
|
||||
target_bucket: String,
|
||||
|
||||
// #[serde(rename = "targetbucket")]
|
||||
// target_bucket: String,
|
||||
secure: bool,
|
||||
|
||||
// #[serde(rename = "secure")]
|
||||
// secure: bool,
|
||||
path: Option<String>,
|
||||
|
||||
// #[serde(rename = "path", skip_serializing_if = "Option::is_none")]
|
||||
// path: Option<String>,
|
||||
api: Option<String>,
|
||||
|
||||
// #[serde(rename = "api", skip_serializing_if = "Option::is_none")]
|
||||
// api: Option<String>,
|
||||
arn: Option<String>,
|
||||
|
||||
// #[serde(rename = "arn", skip_serializing_if = "Option::is_none")]
|
||||
// arn: Option<String>,
|
||||
type_: ServiceType,
|
||||
|
||||
// #[serde(rename = "type")]
|
||||
// type_: ServiceType,
|
||||
region: Option<String>,
|
||||
|
||||
// #[serde(rename = "region", skip_serializing_if = "Option::is_none")]
|
||||
// region: Option<String>,
|
||||
bandwidth_limit: Option<i64>,
|
||||
|
||||
// #[serde(rename = "bandwidthlimit")]
|
||||
// bandwidth_limit: Option<i64>,
|
||||
replication_sync: bool,
|
||||
|
||||
// #[serde(rename = "replicationSync")]
|
||||
// replication_sync: bool,
|
||||
storage_class: Option<String>,
|
||||
|
||||
// #[serde(rename = "storageclass", skip_serializing_if = "Option::is_none")]
|
||||
// storage_class: Option<String>,
|
||||
health_check_duration: Option<Duration>,
|
||||
|
||||
// #[serde(rename = "healthCheckDuration")]
|
||||
// health_check_duration: Option<Duration>,
|
||||
disable_proxy: bool,
|
||||
|
||||
// #[serde(rename = "disableProxy")]
|
||||
// disable_proxy: bool,
|
||||
reset_before_date: Option<OffsetDateTime>,
|
||||
|
||||
// #[serde(rename = "resetBeforeDate", skip_serializing_if = "Option::is_none")]
|
||||
// reset_before_date: Option<SystemTime>,
|
||||
reset_id: Option<String>,
|
||||
|
||||
// #[serde(rename = "resetID", skip_serializing_if = "Option::is_none")]
|
||||
// reset_id: Option<String>,
|
||||
total_downtime: Duration,
|
||||
|
||||
// #[serde(rename = "totalDowntime")]
|
||||
// total_downtime: Duration,
|
||||
last_online: Option<OffsetDateTime>,
|
||||
|
||||
// #[serde(rename = "lastOnline")]
|
||||
// last_online: SystemTime,
|
||||
online: bool,
|
||||
|
||||
// #[serde(rename = "isOnline")]
|
||||
// online: bool,
|
||||
latency: LatencyStat,
|
||||
|
||||
// #[serde(rename = "latency")]
|
||||
// latency: LatencyStat,
|
||||
deployment_id: Option<String>,
|
||||
|
||||
// #[serde(rename = "deploymentID", skip_serializing_if = "Option::is_none")]
|
||||
// deployment_id: Option<String>,
|
||||
edge: bool,
|
||||
}
|
||||
|
||||
// #[serde(rename = "edge")]
|
||||
// edge: bool,
|
||||
// }
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct BucketTargets {
|
||||
pub targets: Vec<BucketTarget>,
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, Default, Deserialize, Serialize)]
|
||||
pub enum State {
|
||||
#[default]
|
||||
Enabled,
|
||||
Suspended,
|
||||
// 如果未来可能会使用到Disabled状态,可以在这里添加
|
||||
@@ -22,12 +25,12 @@ impl std::fmt::Display for State {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct ExcludedPrefix {
|
||||
pub prefix: String,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct Versioning {
|
||||
pub status: State,
|
||||
pub excluded_prefixes: Vec<ExcludedPrefix>,
|
||||
|
||||
@@ -364,6 +364,7 @@ pub struct ReadOptions {
|
||||
// }
|
||||
// }
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum FileWriter {
|
||||
Local(LocalFileWriter),
|
||||
Remote(RemoteFileWriter),
|
||||
@@ -378,7 +379,7 @@ impl Write for FileWriter {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct LocalFileWriter {
|
||||
pub inner: File,
|
||||
}
|
||||
@@ -399,6 +400,7 @@ impl Write for LocalFileWriter {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct RemoteFileWriter {
|
||||
pub root: PathBuf,
|
||||
pub volume: String,
|
||||
|
||||
+1
-1
@@ -16,4 +16,4 @@ pub mod store_api;
|
||||
mod store_init;
|
||||
mod utils;
|
||||
|
||||
mod bucket;
|
||||
pub mod bucket;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![allow(clippy::map_entry)]
|
||||
use crate::{
|
||||
bucket_meta::BucketMetadata,
|
||||
bucket::BucketMetadata,
|
||||
disk::{error::DiskError, new_disk, DiskOption, DiskStore, WalkDirOptions, BUCKET_META_PREFIX, RUSTFS_META_BUCKET},
|
||||
endpoints::{EndpointServerPools, SetupType},
|
||||
error::{Error, Result},
|
||||
|
||||
Reference in New Issue
Block a user