Skip to content

Commit 960ebce

Browse files
committed
Add health check interval
1 parent a3e4aba commit 960ebce

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

client/process_test.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,10 @@ func TestProcesses(t *testing.T) {
119119
"health_check": {
120120
"type": "http",
121121
"data": {
122-
"timeout": 60
122+
"timeout": 60,
123+
"invocation_timeout": 5,
124+
"interval": 10,
125+
"endpoint": "/health"
123126
}
124127
}
125128
}`,
@@ -129,7 +132,10 @@ func TestProcesses(t *testing.T) {
129132
r := resource.NewProcessUpdate().
130133
WithCommand("rackup").
131134
WithHealthCheckType("http").
132-
WithHealthCheckTimeout(60)
135+
WithHealthCheckTimeout(60).
136+
WithHealthCheckInterval(10).
137+
WithHealthCheckInvocationTimeout(5).
138+
WithHealthCheckEndpoint("/health")
133139
return c.Processes.Update(context.Background(), "ec4ff362-60c5-47a0-8246-2a134537c606", r)
134140
},
135141
},

resource/process.go

+11
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ type ProcessData struct {
9191
// The timeout in seconds for individual health check requests for http and port health checks
9292
InvocationTimeout *int `json:"invocation_timeout,omitempty"`
9393

94+
// The interval in seconds between health check requests
95+
Interval *int `json:"interval,omitempty"`
96+
9497
// The endpoint called to determine if the app is healthy; this key is only present for http health check
9598
Endpoint *string `json:"endpoint,omitempty"`
9699
}
@@ -164,6 +167,14 @@ func (p *ProcessUpdate) WithHealthCheckInvocationTimeout(timeout int) *ProcessUp
164167
return p
165168
}
166169

170+
func (p *ProcessUpdate) WithHealthCheckInterval(interval int) *ProcessUpdate {
171+
if p.HealthCheck == nil {
172+
p.HealthCheck = &ProcessHealthCheck{}
173+
}
174+
p.HealthCheck.Data.Interval = &interval
175+
return p
176+
}
177+
167178
func (p *ProcessUpdate) WithHealthCheckEndpoint(endpoint string) *ProcessUpdate {
168179
if p.HealthCheck == nil {
169180
p.HealthCheck = &ProcessHealthCheck{}

testutil/template/process.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
"disk_in_mb": 1024,
88
"log_rate_limit_in_bytes_per_second": 1024,
99
"health_check": {
10-
"type": "port",
10+
"type": "http",
1111
"data": {
12-
"timeout": null
12+
"timeout": 60,
13+
"invocation_timeout": 5,
14+
"interval": 10,
15+
"endpoint": "/health"
1316
}
1417
},
1518
"relationships": {

0 commit comments

Comments
 (0)