Skip to content

Commit

Permalink
add readiness health check support in client
Browse files Browse the repository at this point in the history
  • Loading branch information
Yavor16 committed Feb 7, 2024
1 parent 02b9882 commit 833a8a1
Show file tree
Hide file tree
Showing 16 changed files with 356 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@
import org.cloudfoundry.client.v3.processes.ProcessState;
import org.cloudfoundry.client.v3.processes.ProcessStatisticsResource;
import org.cloudfoundry.client.v3.processes.ProcessUsage;
import org.cloudfoundry.client.v3.processes.ReadinessHealthCheck;
import org.cloudfoundry.client.v3.processes.ReadinessHealthCheckType;
import org.cloudfoundry.client.v3.routes.Application;
import org.cloudfoundry.client.v3.routes.Destination;
import org.cloudfoundry.client.v3.routes.Process;
Expand Down Expand Up @@ -807,6 +809,16 @@ public void getProcess() {
.endpoint(null)
.build())
.build())
.readinessHealthCheck(
ReadinessHealthCheck.builder()
.type(ReadinessHealthCheckType.PORT)
.data(
Data.builder()
.interval(null)
.timeout(null)
.endpoint(null)
.build())
.build())
.metadata(
Metadata.builder()
.annotations(Collections.emptyMap())
Expand Down Expand Up @@ -1627,6 +1639,16 @@ public void listProcesses() {
.endpoint(null)
.build())
.build())
.readinessHealthCheck(
ReadinessHealthCheck.builder()
.type(ReadinessHealthCheckType.PORT)
.data(
Data.builder()
.interval(null)
.timeout(null)
.endpoint(null)
.build())
.build())
.metadata(
Metadata.builder()
.annotations(Collections.emptyMap())
Expand Down Expand Up @@ -1685,6 +1707,16 @@ public void listProcesses() {
.endpoint(null)
.build())
.build())
.readinessHealthCheck(
ReadinessHealthCheck.builder()
.type(ReadinessHealthCheckType.PORT)
.data(
Data.builder()
.interval(null)
.timeout(null)
.endpoint(null)
.build())
.build())
.metadata(
Metadata.builder()
.annotations(Collections.emptyMap())
Expand Down Expand Up @@ -2052,6 +2084,16 @@ public void scale() {
.endpoint(null)
.build())
.build())
.readinessHealthCheck(
ReadinessHealthCheck.builder()
.type(ReadinessHealthCheckType.PORT)
.data(
Data.builder()
.interval(null)
.timeout(null)
.endpoint(null)
.build())
.build())
.metadata(
Metadata.builder()
.annotations(Collections.emptyMap())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
import org.cloudfoundry.client.v3.processes.ProcessState;
import org.cloudfoundry.client.v3.processes.ProcessStatisticsResource;
import org.cloudfoundry.client.v3.processes.ProcessUsage;
import org.cloudfoundry.client.v3.processes.ReadinessHealthCheck;
import org.cloudfoundry.client.v3.processes.ReadinessHealthCheckType;
import org.cloudfoundry.client.v3.processes.ScaleProcessRequest;
import org.cloudfoundry.client.v3.processes.ScaleProcessResponse;
import org.cloudfoundry.client.v3.processes.TerminateProcessInstanceRequest;
Expand Down Expand Up @@ -121,6 +123,16 @@ public void get() {
.endpoint(null)
.build())
.build())
.readinessHealthCheck(
ReadinessHealthCheck.builder()
.type(ReadinessHealthCheckType.PORT)
.data(
Data.builder()
.interval(null)
.timeout(null)
.endpoint(null)
.build())
.build())
.metadata(
Metadata.builder()
.annotations(Collections.emptyMap())
Expand Down Expand Up @@ -309,6 +321,16 @@ public void list() {
.endpoint(null)
.build())
.build())
.readinessHealthCheck(
ReadinessHealthCheck.builder()
.type(ReadinessHealthCheckType.PORT)
.data(
Data.builder()
.interval(null)
.timeout(null)
.endpoint(null)
.build())
.build())
.metadata(
Metadata.builder()
.annotations(Collections.emptyMap())
Expand Down Expand Up @@ -367,6 +389,16 @@ public void list() {
.endpoint(null)
.build())
.build())
.readinessHealthCheck(
ReadinessHealthCheck.builder()
.type(ReadinessHealthCheckType.PORT)
.data(
Data.builder()
.interval(null)
.timeout(null)
.endpoint(null)
.build())
.build())
.metadata(
Metadata.builder()
.annotations(Collections.emptyMap())
Expand Down Expand Up @@ -458,6 +490,16 @@ public void scale() {
.endpoint(null)
.build())
.build())
.readinessHealthCheck(
ReadinessHealthCheck.builder()
.type(ReadinessHealthCheckType.PORT)
.data(
Data.builder()
.interval(null)
.timeout(null)
.endpoint(null)
.build())
.build())
.metadata(
Metadata.builder()
.annotations(Collections.emptyMap())
Expand Down Expand Up @@ -545,6 +587,16 @@ public void update() {
.endpoint(null)
.build())
.build())
.readinessHealthCheck(
ReadinessHealthCheck.builder()
.type(ReadinessHealthCheckType.PORT)
.data(
Data.builder()
.interval(null)
.timeout(null)
.endpoint(null)
.build())
.build())
.metadata(
Metadata.builder()
.annotations(Collections.emptyMap())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
"endpoint": null
}
},
"readiness_health_check": {
"type": "port",
"data": {
"interval": null,
"endpoint": null,
"invocation_timeout": null
}
},
"metadata": {
"annotations": {},
"labels": {}
Expand Down Expand Up @@ -68,6 +76,14 @@
"endpoint": null
}
},
"readiness_health_check": {
"type": "port",
"data": {
"interval": null,
"endpoint": null,
"invocation_timeout": null
}
},
"metadata": {
"annotations": {},
"labels": {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
"endpoint": null
}
},
"readiness_health_check": {
"type": "port",
"data": {
"interval": null,
"endpoint": null,
"invocation_timeout": null
}
},
"metadata": {
"annotations": {},
"labels": {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
"endpoint": null
}
},
"readiness_health_check": {
"type": "port",
"data": {
"interval": null,
"endpoint": null,
"invocation_timeout": null
}
},
"metadata": {
"annotations": {},
"labels": {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
"endpoint": null
}
},
"readiness_health_check": {
"type": "port",
"data": {
"interval": null,
"endpoint": null,
"invocation_timeout": null
}
},
"metadata": {
"annotations": {},
"labels": {}
Expand Down Expand Up @@ -68,6 +76,14 @@
"endpoint": null
}
},
"readiness_health_check": {
"type": "port",
"data": {
"interval": null,
"endpoint": null,
"invocation_timeout": null
}
},
"metadata": {
"annotations": {},
"labels": {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
"endpoint": null
}
},
"readiness_health_check": {
"type": "port",
"data": {
"interval": null,
"endpoint": null,
"invocation_timeout": null
}
},
"metadata": {
"annotations": {},
"labels": {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
"endpoint": null
}
},
"readiness_health_check": {
"type": "port",
"data": {
"interval": null,
"endpoint": null,
"invocation_timeout": null
}
},
"metadata": {
"annotations": {},
"labels": {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
"endpoint": null
}
},
"readiness_health_check": {
"type": "port",
"data": {
"interval": null,
"endpoint": null,
"invocation_timeout": null
}
},
"metadata": {
"annotations": {},
"labels": {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ public abstract class Process extends Resource {
@JsonProperty("health_check")
public abstract HealthCheck getHealthCheck();

/**
* The readiness health check
*/
@JsonProperty("readiness_health_check")
public abstract ReadinessHealthCheck getReadinessHealthCheck();

/**
* The instances
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright 2013-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.cloudfoundry.client.v3.processes;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

public enum ReadinessHealthCheckType {

/**
* An http health check
*/
HTTP("http"),

/**
* A port health check
*/
PORT("port"),

/**
* A process health check
*/
PROCESS("process");

private final String value;

ReadinessHealthCheckType(String value) {
this.value = value;
}

@JsonCreator
public static ReadinessHealthCheckType from(String s) {
switch (s.toLowerCase()) {
case "http":
return HTTP;
case "port":
return PORT;
case "process":
return PROCESS;
default:
throw new IllegalArgumentException(
String.format("Unknown health check type: %s", s));
}
}

@JsonValue
public String getValue() {
return this.value;
}

@Override
public String toString() {
return getValue();
}
}
Loading

0 comments on commit 833a8a1

Please sign in to comment.