sentinel-group / sentinel-rust

Sentinel Rust version
Apache License 2.0
132 stars 22 forks source link

Reexport crates for direct user access #129

Closed flearc closed 8 months ago

flearc commented 9 months ago

When using Consul as a datasource, users currently need to provide a Consul client and query options to instantiate ConsulDatasource. This involves importing the consul crate to create the client.

impl<P: SentinelRule + PartialEq + DeserializeOwned, H: PropertyHandler<P>> ConsulDataSource<P, H> {
    pub fn new(
        client: Client,
        query_options: QueryOptions,
        property: String,
        handlers: Vec<Arc<H>>,
    ) -> Self {
        let mut ds = DataSourceBase::default();
        for h in handlers {
            // incase of duplication, add it one by one, instead of adding all at once
            ds.add_property_handler(h);
        }
        ConsulDataSource {
            ds,
            query_options,
            property,
            client,
            closed: AtomicBool::new(false),
        }
    }
    ...
}

To streamline this process and mitigate potential version mismatches, consider reexporting the consul crate. By doing so, users can avoid explicit crate imports, simplifying the setup and enhancing compatibility.

Additionally, other crates may also can be reexported:

Forsworns commented 8 months ago

It's a good idea, and I guess these crates need upgradation, too.

flearc commented 8 months ago

Sorry for late reply, I will raise a PR when I have time.