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

Added Rotation Management #63

Merged
merged 13 commits into from
Apr 1, 2024
Merged

Conversation

ajaypj
Copy link
Collaborator

@ajaypj ajaypj commented Mar 20, 2024

No description provided.

Comment on lines 47 to 61
@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();
}
Copy link
Member

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed

Comment on lines 17 to 35
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();
}
}
}
Copy link
Member

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?

Copy link
Collaborator Author

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,
Copy link
Member

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.

Copy link
Collaborator Author

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);
Copy link
Collaborator

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

Copy link
Collaborator Author

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
Copy link
Collaborator

@spawn92 spawn92 Mar 27, 2024

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*");

Copy link
Collaborator Author

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;
Copy link
Collaborator

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 ?

Copy link
Collaborator Author

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;
Copy link
Collaborator

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 .

Copy link
Collaborator Author

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.");
Copy link
Collaborator

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.

Copy link
Collaborator Author

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;
Copy link
Collaborator

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

Copy link
Collaborator Author

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);
Copy link
Collaborator

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?

Copy link
Member

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed AllIsWellHealthCheck

Copy link
Member

@kingster kingster Apr 1, 2024

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

Copy link
Collaborator Author

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;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please revert this file

Copy link
Collaborator Author

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;
Copy link
Collaborator

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 .

Copy link
Collaborator Author

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;
Copy link
Collaborator

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

spawn92
spawn92 previously approved these changes Apr 1, 2024
Copy link
Collaborator

@spawn92 spawn92 left a 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
Copy link
Member

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.

Copy link
Collaborator Author

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() {
Copy link
Member

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@kingster kingster merged commit ed963fa into flipkart-incubator:master Apr 1, 2024
3 checks passed
kingster added a commit that referenced this pull request Apr 2, 2024
* 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)
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.

4 participants