github.com/letsencrypt/boulder@v0.20251208.0/observer/probers/tcp/tcp_conf.go (about) 1 package tcp 2 3 import ( 4 "github.com/letsencrypt/boulder/observer/probers" 5 "github.com/letsencrypt/boulder/strictyaml" 6 "github.com/prometheus/client_golang/prometheus" 7 ) 8 9 // TCPConf is exported to receive YAML configuration. 10 type TCPConf struct { 11 Hostport string `yaml:"hostport"` 12 } 13 14 // Kind returns a name that uniquely identifies the `Kind` of `Configurer`. 15 func (c TCPConf) Kind() string { 16 return "TCP" 17 } 18 19 // UnmarshalSettings takes YAML as bytes and unmarshals it to the to an 20 // TCPConf object. 21 func (c TCPConf) UnmarshalSettings(settings []byte) (probers.Configurer, error) { 22 var conf TCPConf 23 err := strictyaml.Unmarshal(settings, &conf) 24 if err != nil { 25 return nil, err 26 } 27 return conf, nil 28 } 29 30 // MakeProber constructs a `TCPPProbe` object from the contents of the 31 // bound `TCPPConf` object. 32 func (c TCPConf) MakeProber(_ map[string]prometheus.Collector) (probers.Prober, error) { 33 return TCPProbe{c.Hostport}, nil 34 } 35 36 // Instrument is a no-op to implement the `Configurer` interface. 37 func (c TCPConf) Instrument() map[string]prometheus.Collector { 38 return nil 39 } 40 41 // init is called at runtime and registers `TCPConf`, a `Prober` 42 // `Configurer` type, as "TCP". 43 func init() { 44 probers.Register(TCPConf{}) 45 }