appform-io / ranger

Service Discovery for Java
Apache License 2.0
7 stars 12 forks source link

Enhancement : Take a ServiceDataSource as an arg, instead of Collection<Service> in the hubClient #9

Closed koushikr closed 2 years ago

koushikr commented 2 years ago

Instead of taking the Collection in the AbstractRangerHubClient and building the serviceDataSource as follows.

 protected ServiceDataSource buildServiceDataSource() {
        return !services.isEmpty()
               ? new StaticDataSource(services)
               : getDataSource();
    }

Take the ServiceDataSource as an arg. In the above case, if someone intializes a hub without any service, then we end up getting everything from the respective datasource and there is no way for someone to init an empty hub.

While it may be reasonable to expect people to init a hub with services, in theory it may make sense to take in a serviceDataSource as the arg and default to the respective dataSource (http or zk) if service data source is null, in the case of an empty hub, then the clients can do a

new StaticDataSource(Set.of()) and the hub won't still scan the entire client's datasource.

@santanusinha : FYI if this makes sense?

koushikr commented 2 years ago

Closing this, addressed in https://github.com/appform-io/ranger/pull/12