This repository has been archived by the owner on May 11, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CorrelationIds, Collaborators, Pings
- Loading branch information
1 parent
e26967a
commit 2323b7f
Showing
17 changed files
with
220 additions
and
246 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 0 additions & 25 deletions
25
...ring-base/src/main/groovy/com/ofg/infrastructure/correlationid/CorrelationIdHolder.groovy
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
...spring-base/src/main/groovy/com/ofg/infrastructure/correlationid/CorrelationIdHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.ofg.infrastructure.correlationid; | ||
|
||
/** | ||
* Component that stores correlation id using {@link ThreadLocal} | ||
*/ | ||
public class CorrelationIdHolder { | ||
public static final String CORRELATION_ID_HEADER = "correlationId"; | ||
private static final ThreadLocal<String> id = new ThreadLocal<String>(); | ||
|
||
public static void set(String correlationId) { | ||
id.set(correlationId); | ||
} | ||
|
||
public static String get() { | ||
return id.get(); | ||
} | ||
|
||
public static void remove() { | ||
id.remove(); | ||
} | ||
} |
12 changes: 0 additions & 12 deletions
12
...fra-spring-base/src/main/groovy/com/ofg/infrastructure/correlationid/UuidGenerator.groovy
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
...infra-spring-base/src/main/groovy/com/ofg/infrastructure/correlationid/UuidGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.ofg.infrastructure.correlationid; | ||
|
||
import java.util.UUID; | ||
|
||
public class UuidGenerator { | ||
public String create() { | ||
return UUID.randomUUID().toString(); | ||
} | ||
|
||
} |
12 changes: 0 additions & 12 deletions
12
...-spring-base/src/main/groovy/com/ofg/infrastructure/healthcheck/CollaboratorStatus.groovy
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
...ra-spring-base/src/main/groovy/com/ofg/infrastructure/healthcheck/CollaboratorStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.ofg.infrastructure.healthcheck; | ||
|
||
public enum CollaboratorStatus { | ||
UP, DOWN; | ||
|
||
public static CollaboratorStatus of(boolean isUp) { | ||
return isUp ? UP : DOWN; | ||
} | ||
|
||
} |
31 changes: 0 additions & 31 deletions
31
...base/src/main/groovy/com/ofg/infrastructure/healthcheck/CollaboratorsConfiguration.groovy
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
...g-base/src/main/groovy/com/ofg/infrastructure/healthcheck/CollaboratorsConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.ofg.infrastructure.healthcheck; | ||
|
||
import com.ofg.infrastructure.discovery.ServiceResolver; | ||
import com.ofg.infrastructure.web.resttemplate.fluent.ServiceRestClient; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
/** | ||
* Registers {@link PingController} (the microservice health check controller) and {@link CollaboratorsConnectivityController} (provider of a state of microservice connection with dependent services). | ||
* | ||
* @see PingController | ||
* @see CollaboratorsConnectivityController | ||
*/ | ||
@Configuration | ||
public class CollaboratorsConfiguration { | ||
@Bean | ||
public CollaboratorsStatusResolver collaboratorsStatusResolver(ServiceResolver serviceResolver, PingClient pingClient) { | ||
return new CollaboratorsStatusResolver(serviceResolver, pingClient); | ||
} | ||
|
||
@Bean | ||
public PingClient pingClient(ServiceRestClient serviceRestClient) { | ||
return new PingClient(serviceRestClient); | ||
} | ||
|
||
} |
46 changes: 0 additions & 46 deletions
46
...main/groovy/com/ofg/infrastructure/healthcheck/CollaboratorsConnectivityController.groovy
This file was deleted.
Oops, something went wrong.
37 changes: 37 additions & 0 deletions
37
...c/main/groovy/com/ofg/infrastructure/healthcheck/CollaboratorsConnectivityController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.ofg.infrastructure.healthcheck; | ||
|
||
import org.springframework.http.MediaType; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* {@link RestController} providing connection state with services the microservice depends upon. | ||
*/ | ||
@RestController | ||
@RequestMapping(value = "/collaborators", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) | ||
class CollaboratorsConnectivityController { | ||
public CollaboratorsConnectivityController(CollaboratorsStatusResolver collaboratorsStatusResolver) { | ||
this.collaboratorsStatusResolver = collaboratorsStatusResolver; | ||
} | ||
|
||
/** | ||
* Returns information about connection status of microservice with other microservices. | ||
* For properly connected service <b>UP</b> state is provided and <b>DOWN</b> otherwise. | ||
* | ||
* @return connection status | ||
*/ | ||
@RequestMapping | ||
public Map getCollaboratorsConnectivityInfo() { | ||
return collaboratorsStatusResolver.statusOfMyCollaborators(); | ||
} | ||
|
||
@RequestMapping("/all") | ||
public Map getAllCollaboratorsConnectivityInfo() { | ||
return collaboratorsStatusResolver.statusOfAllDependencies(); | ||
} | ||
|
||
private final CollaboratorsStatusResolver collaboratorsStatusResolver; | ||
} |
38 changes: 0 additions & 38 deletions
38
...g-base/src/main/groovy/com/ofg/infrastructure/healthcheck/HealthCheckConfiguration.groovy
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
...ing-base/src/main/groovy/com/ofg/infrastructure/healthcheck/HealthCheckConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.ofg.infrastructure.healthcheck; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.core.io.Resource; | ||
|
||
/** | ||
* Registers {@link PingController} (the microservice health check controller) and {@link CollaboratorsConnectivityController} (provider of a state of microservice connection with dependent services). | ||
* | ||
* @see PingController | ||
* @see CollaboratorsConnectivityController | ||
*/ | ||
@Configuration | ||
@Import(CollaboratorsConfiguration.class) | ||
public class HealthCheckConfiguration { | ||
@Bean | ||
public PingController pingController() { | ||
return new PingController(); | ||
} | ||
|
||
@Bean | ||
public CollaboratorsConnectivityController collaboratorsConnectivityController(CollaboratorsStatusResolver collaboratorsStatusResolver) { | ||
return new CollaboratorsConnectivityController(collaboratorsStatusResolver); | ||
} | ||
|
||
@Bean | ||
public MicroserviceConfigurationController microserviceConfigurationController(@Value("${microservice.config.file:classpath:microservice.json}") Resource microserviceConfig) { | ||
return new MicroserviceConfigurationController(microserviceConfig); | ||
} | ||
|
||
} |
Oops, something went wrong.