|
| 1 | +use async_trait::async_trait; |
| 2 | +use serde_json::Value; |
| 3 | + |
| 4 | +/// @module ConfigProvider |
| 5 | +/// @description Defines the abstract service trait for providing and updating |
| 6 | +/// configuration values. |
| 7 | +use super::dto::{ConfigurationOverridesDto, ConfigurationTarget}; |
| 8 | +use crate::{environment::Environment, error::CommonError}; |
| 9 | + |
| 10 | +/// An abstract service contract for an environment component that can provide |
| 11 | +/// the final, merged configuration values and handle requests to update those |
| 12 | +/// values in their persistent storage (i.e., `settings.json` files). |
| 13 | +#[async_trait] |
| 14 | +pub trait ConfigProvider: Environment + Send + Sync { |
| 15 | + /// Retrieves a configuration value for a given section/key, applying |
| 16 | + /// specified overrides. This should return the final, effective value |
| 17 | + /// after merging all configuration sources. |
| 18 | + /// |
| 19 | + /// @param Section - An optional, dot-separated key to a specific |
| 20 | + /// configuration section. If `None`, the entire configuration object |
| 21 | + /// should be returned. @param Overrides - A DTO specifying scope overrides |
| 22 | + /// (e.g., for a specific resource). |
| 23 | + /// |
| 24 | + /// @returns A `Result` containing the requested configuration as a |
| 25 | + /// `serde_json::Value`. |
| 26 | + async fn GetConfigurationValue( |
| 27 | + &self, |
| 28 | + Section:Option<String>, |
| 29 | + Overrides:ConfigurationOverridesDto, |
| 30 | + ) -> Result<Value, CommonError>; |
| 31 | + |
| 32 | + /// Updates a configuration value at a specific key and target scope. |
| 33 | + /// |
| 34 | + /// @param Key - The dot-separated configuration key to update. |
| 35 | + /// @param ValueToSet - The new `serde_json::Value` to set for the key. |
| 36 | + /// @param Target - The `ConfigurationTarget` enum specifying which scope to |
| 37 | + /// write to (e.g., User, Workspace). |
| 38 | + /// @param Overrides - A DTO for scope overrides. |
| 39 | + /// @param ScopeToLanguage - An optional flag related to language-specific |
| 40 | + /// settings. |
| 41 | + async fn UpdateConfigurationValue( |
| 42 | + &self, |
| 43 | + Key:String, |
| 44 | + ValueToSet:Value, |
| 45 | + Target:ConfigurationTarget, |
| 46 | + Overrides:ConfigurationOverridesDto, |
| 47 | + ScopeToLanguage:Option<bool>, |
| 48 | + ) -> Result<(), CommonError>; |
| 49 | +} |
0 commit comments