summaryrefslogtreecommitdiff
path: root/service/health/config.go
blob: 60a52d6ec6fd5c1502186bce4dff70107da38f15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
}