Skip to content

Conversation

jgsogo
Copy link
Collaborator

@jgsogo jgsogo commented Dec 16, 2024

closes #31

Now that I've written this, I wonder if it would be easier to have a AppConfigurationClient trait and multiple implementations:

AppConfigurationIBMCloud::new(region, api_key);

AppConfigurationLocal::new(filepath);

AppConfigurationURLServer::new(url);

@jgsogo jgsogo marked this pull request as ready for review December 16, 2024 14:04
@jgsogo
Copy link
Collaborator Author

jgsogo commented Dec 16, 2024

pub trait AppConfigurationClient {  
   fn get_feature(&self, feature_id: &str) -> Result<Feature>;
}

// Connecting to IBM Cloud to get the snapshots (and keep them updated)
pub struct AppConfigurationIBMCloud {}

impl AppConfigurationIBMCloud {
   pub fn new(...) -> Self {}
}

impl AppConfigurationClient for AppConfigurationIBMCloud { 
    fn get_feature(&self, feature_id: &str) -> Result<Feature> {
        todo!("impl")
    }
};

// Reading the snapshot from a file
pub struct AppConfigurationFileSnapshot {}

impl AppConfigurationFileSnapshot {
   pub fn new(...) -> Self {}
}

impl AppConfigurationClient for AppConfigurationFileSnapshot { 
    fn get_feature(&self, feature_id: &str) -> Result<Feature> {
        todo!("impl")
    }
};

@jgsogo
Copy link
Collaborator Author

jgsogo commented Dec 16, 2024

superseded by #34

@jgsogo jgsogo closed this Dec 16, 2024
@jgsogo jgsogo deleted the feat/builder-pattern branch December 16, 2024 16:11
jgsogo added a commit that referenced this pull request Dec 17, 2024
closes #31, but using a more idiomatic approach (for the complexity we
have right now):
 * `AppConfigurationClient` trait, and 
 * `AppConfigurationClientIBMCloud` implementation

---

See #32 for more
details and discarded alternatives

---------

Signed-off-by: Javier G. Sogo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Builder pattern
1 participant