spring-cloud-commons icon indicating copy to clipboard operation
spring-cloud-commons copied to clipboard

Features endpoint does not show disabled named feature

Open kzwang opened this issue 6 years ago • 6 comments

For abstract feature, it checks whether there is a bean for that type or not, however, for named feature, it always adds to enabled features, instead of adding to disabled feature when there is no bean of the specified type (due to @ConditionalOn...)

kzwang avatar Nov 20 '19 04:11 kzwang

the named feature doesn't match to a bean so there is nothing to check.

spencergibb avatar Jan 14 '20 01:01 spencergibb

@spencergibb here is the use case example I'm thinking of:

@Bean
@ConditionalOnProperty("test.enabled"...)
public TestBean testBean() {
    return new TestBean();
}

@Bean
public HasFeatures testFeature() {
  return HasFeatures.namedFeatures(
    new NamedFeature("Feature 1", TestBean.class));
}

Then the features endpoint would return "Feature 1" in disabled features if test.enabled=false, currently, it doesn't display "Feature 1" at all.

Let me know if this is not the intended use case of features endpoint.

kzwang avatar Jan 14 '20 02:01 kzwang

They should be in a single class that is conditional on property or share the same conditional

spencergibb avatar Jan 14 '20 02:01 spencergibb

They should be in a single class that is conditional on property or share the same conditional

Sorry, my previous comment was wrong. If they share the same conditional, then when that's disabled, "Feature 1" won't be displayed as "disabled" as there is no bean for the named feature as well. If not share the same conditional, then "Feature 1" is always in the enabled list.

I'd like to get the list of all enabled and disabled features in that endpoint. Currently, for named features, it can only exist in the enabled list or not in the features endpoint at all, it will never exist in the disabled list.

kzwang avatar Jan 14 '20 03:01 kzwang

I can't think of a way to do it with named features.

spencergibb avatar Jan 14 '20 03:01 spencergibb

Here is what I'm thinking:

  • HasFeatures beans will never be conditional
  • NamedFeatures contains the bean type or bean name (and maybe multiple bean types/names)
  • Features endpoint will check for bean type/named, and if bean exists, add to the enabled list, otherwise add to the disabled list

cc @twicksell any thoughts?

kzwang avatar Jan 14 '20 04:01 kzwang