Documentation ¶
Index ¶
- Constants
- func NewCheck() checks.Check
- type Config
- type DNS
- func (d *DNS) GetConfig() checks.Runtime
- func (d *DNS) GetMetricCollectors() []prometheus.Collector
- func (d *DNS) Name() string
- func (d *DNS) RemoveLabelledMetrics(target string) error
- func (d *DNS) Run(ctx context.Context, cResult chan checks.ResultDTO) error
- func (d *DNS) Schema() (*openapi3.SchemaRef, error)
- func (d *DNS) Shutdown()
- func (d *DNS) UpdateConfig(cfg checks.Runtime) error
- type Resolver
- type ResolverMock
- func (mock *ResolverMock) LookupAddr(ctx context.Context, addr string) ([]string, error)
- func (mock *ResolverMock) LookupAddrCalls() []struct{ ... }
- func (mock *ResolverMock) LookupHost(ctx context.Context, addr string) ([]string, error)
- func (mock *ResolverMock) LookupHostCalls() []struct{ ... }
- func (mock *ResolverMock) SetDialer(d *net.Dialer)
- func (mock *ResolverMock) SetDialerCalls() []struct{ ... }
Constants ¶
View Source
const CheckName = "dns"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { Targets []string `json:"targets" yaml:"targets"` Interval time.Duration `json:"interval" yaml:"interval"` Timeout time.Duration `json:"timeout" yaml:"timeout"` Retry helper.RetryConfig `json:"retry" yaml:"retry"` }
Config defines the configuration parameters for a DNS check
type DNS ¶
DNS is a check that resolves the names and addresses
func (*DNS) GetMetricCollectors ¶
func (d *DNS) GetMetricCollectors() []prometheus.Collector
GetMetricCollectors returns all metric collectors of check
func (*DNS) RemoveLabelledMetrics ¶
RemoveLabelledMetrics removes the metrics which have the passed target as a label
type Resolver ¶
type Resolver interface { LookupAddr(ctx context.Context, addr string) ([]string, error) LookupHost(ctx context.Context, addr string) ([]string, error) SetDialer(d *net.Dialer) }
func NewResolver ¶
func NewResolver() Resolver
type ResolverMock ¶
type ResolverMock struct { // LookupAddrFunc mocks the LookupAddr method. LookupAddrFunc func(ctx context.Context, addr string) ([]string, error) // LookupHostFunc mocks the LookupHost method. LookupHostFunc func(ctx context.Context, addr string) ([]string, error) // SetDialerFunc mocks the SetDialer method. SetDialerFunc func(d *net.Dialer) // contains filtered or unexported fields }
ResolverMock is a mock implementation of Resolver.
func TestSomethingThatUsesResolver(t *testing.T) { // make and configure a mocked Resolver mockedResolver := &ResolverMock{ LookupAddrFunc: func(ctx context.Context, addr string) ([]string, error) { panic("mock out the LookupAddr method") }, LookupHostFunc: func(ctx context.Context, addr string) ([]string, error) { panic("mock out the LookupHost method") }, SetDialerFunc: func(d *net.Dialer) { panic("mock out the SetDialer method") }, } // use mockedResolver in code that requires Resolver // and then make assertions. }
func (*ResolverMock) LookupAddr ¶
LookupAddr calls LookupAddrFunc.
func (*ResolverMock) LookupAddrCalls ¶
func (mock *ResolverMock) LookupAddrCalls() []struct { Ctx context.Context Addr string }
LookupAddrCalls gets all the calls that were made to LookupAddr. Check the length with:
len(mockedResolver.LookupAddrCalls())
func (*ResolverMock) LookupHost ¶
LookupHost calls LookupHostFunc.
func (*ResolverMock) LookupHostCalls ¶
func (mock *ResolverMock) LookupHostCalls() []struct { Ctx context.Context Addr string }
LookupHostCalls gets all the calls that were made to LookupHost. Check the length with:
len(mockedResolver.LookupHostCalls())
func (*ResolverMock) SetDialer ¶
func (mock *ResolverMock) SetDialer(d *net.Dialer)
SetDialer calls SetDialerFunc.
func (*ResolverMock) SetDialerCalls ¶
func (mock *ResolverMock) SetDialerCalls() []struct { D *net.Dialer }
SetDialerCalls gets all the calls that were made to SetDialer. Check the length with:
len(mockedResolver.SetDialerCalls())
Click to show internal directories.
Click to hide internal directories.