summaryrefslogtreecommitdiff
path: root/service/health/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'service/health/config.go')
-rw-r--r--service/health/config.go32
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
+}