diff options
author | Alex Price <[email protected]> | 2019-10-12 15:02:57 +1100 |
---|---|---|
committer | Alex Price <[email protected]> | 2019-10-12 15:38:40 +1100 |
commit | c9fdfb6e9484b9aa45e20a90e78a23d5d129308c (patch) | |
tree | 61117f89311b7b8ec2cc680128ecdd1d27d6d94e /service/health/config.go | |
parent | 8a840c40828c1fb31c69fc846a85738ddef0a7c7 (diff) |
adds a health service for determining the status of the workers
This commit adds a health service which ensures that at least
one worker is active. Uses `isActive()` to determine if the
worker is ready. The health service runs on a seperate address.
Will return a HTTP 200 if health, HTTP 500 otherwise.
Fixes #192
Signed-off-by: Alex Price <[email protected]>
Diffstat (limited to 'service/health/config.go')
-rw-r--r-- | service/health/config.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/service/health/config.go b/service/health/config.go new file mode 100644 index 00000000..60a52d6e --- /dev/null +++ b/service/health/config.go @@ -0,0 +1,32 @@ +package health + +import ( + "errors" + "strings" + + "github.com/spiral/roadrunner/service" +) + +// Config configures the health service +type Config struct { + // Address to listen on + Address string +} + +// Hydrate the config +func (c *Config) Hydrate(cfg service.Config) error { + if err := cfg.Unmarshal(c); err != nil { + return err + } + return c.Valid() +} + +// Valid validates the configuration. +func (c *Config) Valid() error { + // Validate the address + if c.Address != "" && !strings.Contains(c.Address, ":") { + return errors.New("malformed http server address") + } + + return nil +} |