-
Notifications
You must be signed in to change notification settings - Fork 18
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
Added Rotation Management #63
Conversation
@GET | ||
@Produces(MediaType.APPLICATION_JSON) | ||
@Path("/status") | ||
public Response status() { | ||
String response = this.manualRotationManagement.getStatus(); | ||
if (this.manualRotationManagement.inHealthy()) { | ||
return Response.status(Response.Status.OK).entity(response).build(); | ||
} | ||
return Response.status(Response.Status.NOT_FOUND).entity(response).build(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really required? Wouldn't the main heathcheck API simply provide the same?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
public class HelloWorldHealthCheckResource { | ||
private ManualRotationManagement manualRotationManagement; | ||
|
||
@Inject | ||
public HelloWorldHealthCheckResource(ManualRotationManagement manualRotationManagement) { | ||
this.manualRotationManagement = manualRotationManagement; | ||
} | ||
|
||
@GET | ||
@Produces(MediaType.APPLICATION_JSON) | ||
@Path("/") | ||
public Response health() { | ||
if (manualRotationManagement.inHealthy()) { | ||
return Response.status(Response.Status.OK).build(); | ||
} else { | ||
return Response.status(Response.Status.SERVICE_UNAVAILABLE).build(); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this resource required? Wouldn't the HealthCheckResource
itself provide this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not required because this functionality is handled by HealthCheckResource. Deleted.
HelloWorldResource2 helloWorldresource2) { | ||
public HelloWorldResourceConfig (HelloWorldResource1 helloWorldresource1, | ||
HelloWorldResource2 helloWorldresource2, | ||
RotationManagementResource rotationManagementResource, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RotationManagementResource
should be by default added, and not required to be explicitly added. Lets change the behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added by default
added RotationManagementConfig and removed binding of RotationManagementResource
register(helloWorldresource1); | ||
register(helloWorldresource2); | ||
register(rotationManagementResource); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be required. We are registering rotationManagement as part of setting up jetty server
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
rotationManagementResourceConfig.register(provider); | ||
ServletHolder rotationManagementServlet = | ||
new ServletHolder(new ServletContainer(rotationManagementResourceConfig)); | ||
context.addServlet(rotationManagementServlet, "/rotation"); // registering Rotation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will have to use wildcard here if you want to register multiple API paths to this servlet .
context.addServlet(rotationManagementServlet, "/rotation*");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated path as /rotation/*
@@ -0,0 +1,24 @@ | |||
package com.flipkart.gjex.core.config; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not see any usage of this ResourceConfig. Can we please remove it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
private static final String BIR = "bir"; | ||
private static final String OOR = "oor"; | ||
|
||
private AtomicBoolean state; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we refactor state attribute to maybe inRotation to signify what it will actually store .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored to rotationStatus
@Override | ||
protected Result check() { | ||
if (isBir()) { | ||
info("Returning healthy status."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel these info logs are not necessary for every health check request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
public class RotationManagementResource { | ||
|
||
@Context | ||
private ServletContext servletContext; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not used . Can we please remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
@@ -56,7 +52,7 @@ protected void configure() { | |||
bind(Filter.class).annotatedWith(Names.named("LoggingFilter")).to(LoggingFilter.class); | |||
bind(Filter.class).annotatedWith(Names.named("AuthFilter")).to(AuthFilter.class); | |||
bind(TracingSampler.class).to(AllWhitelistTracingSampler.class); | |||
bind(HealthCheck.class).to(AllIsWellHealthCheck.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kingster Should we remove AllIsWellHealthCheck.java altogether considering we are providing a health check implementation by default as part of server?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can, but then users shouldn't need to bind this. This should be part of the defaults then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed AllIsWellHealthCheck
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be by default now. Lets change this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now binding of RotationManagementBasedHealthCheck is done in ApiModule
@@ -15,12 +15,14 @@ | |||
*/ | |||
package com.flipkart.gjex.examples.helloworld.web; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverted
@@ -0,0 +1,54 @@ | |||
package com.flipkart.gjex.core.task; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RotationManagementBasedHealthCheck does not belong to core/task package . Can you please create a healthcheck package under code and move healthcheckRegistry.java as well to it .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved
private static final String BIR = "bir"; | ||
private static final String OOR = "oor"; | ||
|
||
private AtomicBoolean state; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make this AtomicBoolean a final as well . We do not require more than 1 instance of this attribute
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
core/src/main/java/com/flipkart/gjex/core/healthcheck/RotationManagementBasedHealthCheck.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
|
||
private RotationManagementBasedHealthCheck rotationManagementBasedHealthCheck; | ||
|
||
@GET |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ajay-jalgaonkar Lets not have this as GET's. A modification status should be an request which cannot be triggered by mistake or by automatic refresh. Lets move this to POST. Same with bir.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
return BIR; | ||
} | ||
|
||
public boolean isBir() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename this method to inRotation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
* master: Added Rotation Management (#63) Create clojars publish pipeline (#65) Create LICENSE (#62) Convert LoggingFilter to Generic<Req, Res> Filter (#61) Update version for current iteration 1.40-SNAPSHOT Make mvn grpc-jexpress-template upto date with Java 17/21 Support (#60) Support for proto-reflections for swagger/postman (#59) Update README.md gRPC & ProtoC Version Bump (#57) Bump fasterxml.jackson version (#58)
No description provided.