Skip to content

Commit

Permalink
Add health check interval
Browse files Browse the repository at this point in the history
  • Loading branch information
sneal committed May 16, 2024
1 parent a3e4aba commit 960ebce
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
10 changes: 8 additions & 2 deletions client/process_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@ func TestProcesses(t *testing.T) {
"health_check": {
"type": "http",
"data": {
"timeout": 60
"timeout": 60,
"invocation_timeout": 5,
"interval": 10,
"endpoint": "/health"
}
}
}`,
Expand All @@ -129,7 +132,10 @@ func TestProcesses(t *testing.T) {
r := resource.NewProcessUpdate().
WithCommand("rackup").
WithHealthCheckType("http").
WithHealthCheckTimeout(60)
WithHealthCheckTimeout(60).
WithHealthCheckInterval(10).
WithHealthCheckInvocationTimeout(5).
WithHealthCheckEndpoint("/health")
return c.Processes.Update(context.Background(), "ec4ff362-60c5-47a0-8246-2a134537c606", r)
},
},
Expand Down
11 changes: 11 additions & 0 deletions resource/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ type ProcessData struct {
// The timeout in seconds for individual health check requests for http and port health checks
InvocationTimeout *int `json:"invocation_timeout,omitempty"`

// The interval in seconds between health check requests
Interval *int `json:"interval,omitempty"`

// The endpoint called to determine if the app is healthy; this key is only present for http health check
Endpoint *string `json:"endpoint,omitempty"`
}
Expand Down Expand Up @@ -164,6 +167,14 @@ func (p *ProcessUpdate) WithHealthCheckInvocationTimeout(timeout int) *ProcessUp
return p
}

func (p *ProcessUpdate) WithHealthCheckInterval(interval int) *ProcessUpdate {
if p.HealthCheck == nil {
p.HealthCheck = &ProcessHealthCheck{}
}
p.HealthCheck.Data.Interval = &interval
return p
}

func (p *ProcessUpdate) WithHealthCheckEndpoint(endpoint string) *ProcessUpdate {
if p.HealthCheck == nil {
p.HealthCheck = &ProcessHealthCheck{}
Expand Down
7 changes: 5 additions & 2 deletions testutil/template/process.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
"disk_in_mb": 1024,
"log_rate_limit_in_bytes_per_second": 1024,
"health_check": {
"type": "port",
"type": "http",
"data": {
"timeout": null
"timeout": 60,
"invocation_timeout": 5,
"interval": 10,
"endpoint": "/health"
}
},
"relationships": {
Expand Down

0 comments on commit 960ebce

Please sign in to comment.