Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add write operation to change toggle state via Spring Boot Actuator #310

Merged
merged 3 commits into from
Dec 22, 2018

Conversation

kschlesselmann
Copy link
Contributor

Resolves: #308

Copy link
Contributor

@ruifigueira ruifigueira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks great! I added some reviews for minor improvements.

@@ -36,9 +39,14 @@
@Endpoint(id = "togglz")
public class TogglzEndpoint {

private final FeatureProvider featureProvider;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need FeatureProvider. You can get the list of features with featureManager.getFeatures(), like in getAllFeatures methods.


@WriteOperation
public TogglzFeature setFeatureState(@Selector String featureName, boolean enabled) {
final Feature feature = featureProvider.getFeatures().stream()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use featureManager.getFeatures() here instead.

return new TogglzFeature(feature, featureState);
}

return null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer if we still returned a TogglzFeature even if the state didn't change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I'd be nice to return null here because in that case the actuator will respond with HTTP 204 instead of HTTP 200 which enables the client to deal with no actual changes (if someone would need that).

If you still prefer to return something else let's discuss that. In order to provide a more advanced HTTP response we need to add a @EndpointWebExtension I think.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I understood your idea, but I still think we should return a richer object. With @EndpointWebExtension that seems to be possible, so maybe we should go that way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, now the endpoint always performs the set feature state operation and returns its result.

@ruifigueira ruifigueira merged commit c6183b5 into togglz:master Dec 22, 2018
@gsteinacker gsteinacker added this to the 2.7.0.Final milestone Oct 15, 2019
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.

Write Endpoints for Spring Boot Actuator
3 participants