Skip to content

Instantly share code, notes, and snippets.

View eldermoraes's full-sized avatar
🤓
Coding

Elder Moraes eldermoraes

🤓
Coding
View GitHub Profile
@Path("/mymetrics")
public class MetricsResource {
@GET
@Path("counted")
@Counted
public String getCounted(){
return "Counted";
}
@Path("/trace")
public class TraceResource {
@GET
@Traced
public String getTrace(){
return "Trace";
}
}
@Readiness
public class ReadinessCheck implements HealthCheck {
@Override
public HealthCheckResponse call() {
Client client = ClientBuilder.newClient();
Response response = client.target("https://eldermoraes.com").request().get();
if (response.getStatusInfo().getFamily().equals(Response.Status.Family.SUCCESSFUL)){
return HealthCheckResponse.up("I'm ready!");
@Liveness
public class LivenessCheck implements HealthCheck {
@Override
public HealthCheckResponse call() {
return HealthCheckResponse.up("I'm alive!");
}
}
@Path("/circuit")
public class CircuitResource {
@Timeout(unit = ChronoUnit.MILLIS, value = 500)
@Fallback(fallbackMethod = "fallback")
@CircuitBreaker(requestVolumeThreshold = 4, failureRatio = 0.5, delay = 2000, delayUnit = ChronoUnit.MILLIS, successThreshold = 2)
@GET
public String getCircuit() throws InterruptedException {
Thread.sleep(600);
return "Circuit \n";
@Path("/config")
public class ConfigResource {
@ConfigProperty(name = "config")
private Optional<String> config;
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getConfig(){
return Response.ok("Hello, " + config.orElse("Optional")).build() ;
module coffee.shop {
requires coffee.module;
}
package coffee.shop;
import coffee.module.Coffee;
public class CoffeeShop {
public static void main(String[] args) {
System.out.println("Enjoy your " + Coffee.name());
}
}
module coffee.module {
exports coffee.module;
}