Skip to content

Commit

Permalink
Add JSON schema
Browse files Browse the repository at this point in the history
Add health_check_timeout option
  • Loading branch information
nickdnk committed Oct 24, 2024
1 parent b1a09f6 commit 68e09a7
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
5 changes: 5 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import "net/http"
type Config struct {
// Address of the http server
Address string
// Time to wait for a health check response.
HealthCheckTimeout int `mapstructure:"health_check_timeout"`
// Status code returned in case of fail, 503 by default
UnavailableStatusCode int `mapstructure:"unavailable_status_code"`
}
Expand All @@ -15,4 +17,7 @@ func (c *Config) InitDefaults() {
if c.UnavailableStatusCode == 0 {
c.UnavailableStatusCode = http.StatusServiceUnavailable
}
if c.HealthCheckTimeout <= 0 {
c.HealthCheckTimeout = 60
}
}
4 changes: 2 additions & 2 deletions plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ func (c *Plugin) Serve() chan error {
Addr: c.cfg.Address,
Handler: mux,
DisableGeneralOptionsHandler: false,
ReadTimeout: time.Minute,
ReadHeaderTimeout: time.Minute,
ReadTimeout: time.Duration(c.cfg.HealthCheckTimeout) * time.Second,
ReadHeaderTimeout: time.Duration(c.cfg.HealthCheckTimeout) * time.Second,
WriteTimeout: time.Minute,
IdleTimeout: time.Minute,
}
Expand Down
34 changes: 34 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"$id": "https://raw.githubusercontent.com/roadrunner-server/status/refs/heads/master/schema.json",
"$schema": "https://json-schema.org/draft/2019-09/schema",
"description": "All the valid configuration parameters for the Health Check (Status) plugin for RoadRunner.",
"type": "object",
"title": "roadrunner-status",
"additionalProperties": false,
"required": [
"address"
],
"properties": {
"address": {
"description": "Host and port to listen on (eg.: `127.0.0.1:2114`). To query a plugin, pass its name as a query parameter called `plugin`, e.g. to check the `http` plugin, GET http://127.0.0.1:2114/health?plugin=http. You can query multiple plugins by appending multiple instances of the `plugin` parameter, e.g. GET http://127.0.0.1:2114/health?plugin=http&plugin=rpc.",
"type": "string",
"minLength": 1,
"examples": [
"127.0.0.1:2114"
]
},
"unavailable_status_code": {
"description": "Response HTTP status code if a requested plugin is not ready to handle requests. Valid for both /health and /ready endpoints. Defaults to 503 if undefined or zero.",
"type": "integer",
"minimum": 100,
"maximum": 599,
"default": 503
},
"health_check_timeout": {
"description": "The time to wait for a complete response from the internal health endpoint. Defaults to 60.",
"type": "integer",
"minimum": 1,
"default": 60
}
}
}

0 comments on commit 68e09a7

Please sign in to comment.