Skip to content

Commit 68ea493

Browse files
Ifeanyi Kaluikalu
authored andcommitted
Add simple healthcheck api
1 parent 61bc3b9 commit 68ea493

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

src/main/java/com/github/tomakehurst/wiremock/client/HttpAdminClient.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,11 @@ public GetGlobalSettingsResult getGlobalSettings() {
432432
adminRoutes.requestSpecForTask(GetGlobalSettingsTask.class), GetGlobalSettingsResult.class);
433433
}
434434

435+
@Override
436+
public boolean isHealthy() {
437+
return executeRequest(adminRoutes.requestSpecForTask(HealthCheckTask.class), Boolean.class);
438+
}
439+
435440
public int port() {
436441
return port;
437442
}

src/main/java/com/github/tomakehurst/wiremock/core/Admin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import com.github.tomakehurst.wiremock.verification.*;
2929
import java.util.UUID;
3030

31-
public interface Admin {
31+
public interface Admin extends HealthChecker {
3232

3333
void addStubMapping(StubMapping stubMapping);
3434

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright (C) 2023 Thomas Akehurst
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.github.tomakehurst.wiremock.core;
17+
18+
public interface HealthChecker {
19+
default boolean isHealthy() {
20+
return true;
21+
}
22+
}

0 commit comments

Comments
 (0)