-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Development: Add health indicator api (#15)
- Loading branch information
Showing
7 changed files
with
88 additions
and
1 deletion.
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
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 |
---|---|---|
|
@@ -5,4 +5,6 @@ | |
public interface SendService<T> { | ||
|
||
ResponseEntity<Void> send(T request); | ||
|
||
boolean isHealthy(); | ||
} |
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
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 |
---|---|---|
|
@@ -27,3 +27,7 @@ dependencies { | |
tasks.named('test') { | ||
useJUnitPlatform() | ||
} | ||
|
||
springBoot { | ||
buildInfo() | ||
} |
20 changes: 20 additions & 0 deletions
20
hermes/src/main/java/de/tum/cit/artemis/push/HealthController.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,20 @@ | ||
package de.tum.cit.artemis.push; | ||
|
||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/api") | ||
public class HealthController { | ||
private final NotificationHealthService healthService; | ||
|
||
public HealthController(NotificationHealthService healthService) { | ||
this.healthService = healthService; | ||
} | ||
|
||
@GetMapping("/health") | ||
public HealthReport getHealth() { | ||
return healthService.getHealthReport(); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
hermes/src/main/java/de/tum/cit/artemis/push/HealthReport.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,4 @@ | ||
package de.tum.cit.artemis.push; | ||
|
||
public record HealthReport(boolean isApnsConnected, boolean isFirebaseConnected, String versionNumber) { | ||
} |
23 changes: 23 additions & 0 deletions
23
hermes/src/main/java/de/tum/cit/artemis/push/NotificationHealthService.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,23 @@ | ||
package de.tum.cit.artemis.push; | ||
|
||
import de.tum.cit.artemis.push.apns.ApnsSendService; | ||
import de.tum.cit.artemis.push.firebase.FirebaseSendService; | ||
import org.springframework.boot.info.BuildProperties; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class NotificationHealthService { | ||
private final FirebaseSendService firebaseSendService; | ||
private final ApnsSendService apnsSendService; | ||
private final BuildProperties buildProperties; | ||
|
||
NotificationHealthService(FirebaseSendService firebaseSendService, ApnsSendService apnsSendService, BuildProperties buildProperties) { | ||
this.firebaseSendService = firebaseSendService; | ||
this.apnsSendService = apnsSendService; | ||
this.buildProperties = buildProperties; | ||
} | ||
|
||
public HealthReport getHealthReport() { | ||
return new HealthReport(apnsSendService.isHealthy(), firebaseSendService.isHealthy(), buildProperties.getVersion()); | ||
} | ||
} |