mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-08 14:23:13 +00:00
dd7da015e3
* init rustfs config * improve code for rustfs-config crate * add * improve code for comment * fix: modify rustfs-config crate name * add default fn * improve error logger * fix: modify docker config yaml * improve code for config * feat: restrict kafka feature to Linux only - Add target-specific feature configuration in Cargo.toml for obs and event-notifier crates - Implement conditional compilation for kafka feature only on Linux systems - Add appropriate error handling for non-Linux platforms - Ensure backward compatibility with existing code * refactor(ci): optimize build workflow for better efficiency - Integrate GUI build steps into main build-rustfs job - Add conditional GUI build execution based on tag releases - Simplify workflow by removing redundant build-rustfs-gui job - Copy binary directly to embedded-rustfs directory without downloading artifacts - Update merge job dependency to only rely on build-rustfs - Improve cross-platform compatibility for Windows binary naming (.exe) - Streamline artifact uploading and OSS publishing process - Maintain consistent conditional logic for release operations * refactor(ci): optimize build workflow for better efficiency - Integrate GUI build steps into main build-rustfs job - Add conditional GUI build execution based on tag releases - Simplify workflow by removing redundant build-rustfs-gui job - Copy binary directly to embedded-rustfs directory without downloading artifacts - Update merge job dependency to only rely on build-rustfs - Improve cross-platform compatibility for Windows binary naming (.exe) - Streamline artifact uploading and OSS publishing process - Maintain consistent conditional logic for release operations * fix(ci): add repo-token to setup-protoc action for authentication - Add GITHUB_TOKEN parameter to arduino/setup-protoc@v3 action - Ensure proper authentication for Protoc installation in CI workflow - Maintain consistent setup across different CI environments * modify config * improve readme.md * remove env config relation * add allow(dead_code)
52 lines
1.4 KiB
Rust
52 lines
1.4 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
use std::collections::HashMap;
|
|
|
|
/// Configuration for the notification system.
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct WebhookAdapter {
|
|
pub endpoint: String,
|
|
pub auth_token: Option<String>,
|
|
pub custom_headers: Option<HashMap<String, String>>,
|
|
pub max_retries: u32,
|
|
pub timeout: u64,
|
|
}
|
|
|
|
impl WebhookAdapter {
|
|
/// verify that the configuration is valid
|
|
pub fn validate(&self) -> Result<(), String> {
|
|
// verify that endpoint cannot be empty
|
|
if self.endpoint.trim().is_empty() {
|
|
return Err("Webhook endpoint cannot be empty".to_string());
|
|
}
|
|
|
|
// verification timeout must be reasonable
|
|
if self.timeout == 0 {
|
|
return Err("Webhook timeout must be greater than 0".to_string());
|
|
}
|
|
|
|
// Verify that the maximum number of retry is reasonable
|
|
if self.max_retries > 10 {
|
|
return Err("Maximum retry count cannot exceed 10".to_string());
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
|
|
/// Get the default configuration
|
|
pub fn new() -> Self {
|
|
Self {
|
|
endpoint: "".to_string(),
|
|
auth_token: None,
|
|
custom_headers: Some(HashMap::new()),
|
|
max_retries: 3,
|
|
timeout: 1000,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Default for WebhookAdapter {
|
|
fn default() -> Self {
|
|
Self::new()
|
|
}
|
|
}
|