Documentation ¶
Index ¶
- Variables
- func OpenapiFromPerfData[T any](data T) (*openapi3.SchemaRef, error)
- type Check
- type CheckBase
- type CheckMock
- func (mock *CheckMock) GetConfig() Runtime
- func (mock *CheckMock) GetConfigCalls() []struct{}
- func (mock *CheckMock) GetMetricCollectors() []prometheus.Collector
- func (mock *CheckMock) GetMetricCollectorsCalls() []struct{}
- func (mock *CheckMock) Name() string
- func (mock *CheckMock) NameCalls() []struct{}
- func (mock *CheckMock) Run(ctx context.Context, cResult chan ResultDTO) error
- func (mock *CheckMock) RunCalls() []struct{ ... }
- func (mock *CheckMock) Schema() (*openapi3.SchemaRef, error)
- func (mock *CheckMock) SchemaCalls() []struct{}
- func (mock *CheckMock) SetConfig(config Runtime) error
- func (mock *CheckMock) SetConfigCalls() []struct{ ... }
- func (mock *CheckMock) Shutdown()
- func (mock *CheckMock) ShutdownCalls() []struct{}
- type ErrConfigMismatch
- type ErrInvalidConfig
- type GlobalTarget
- type Result
- type ResultDTO
- type Runtime
Constants ¶
This section is empty.
Variables ¶
var DefaultRetry = helper.RetryConfig{ Count: 3, Delay: time.Second, }
DefaultRetry provides a default configuration for the retry mechanism
Functions ¶
func OpenapiFromPerfData ¶
OpenapiFromPerfData takes in check perfdata and returns an openapi3.SchemaRef of a result wrapping the perfData this is a workaround, since the openapi3gen.NewSchemaRefForValue function does not work with any types
Types ¶
type Check ¶
type Check interface { // Run is called once, to start running the check. The check should // run until the context is canceled and handle problems itself. // Returning a non-nil error will cause the shutdown of the check. Run(ctx context.Context, cResult chan ResultDTO) error // Shutdown is called once when the check is unregistered or sparrow shuts down Shutdown() // SetConfig is called once when the check is registered // This is also called while the check is running, if the remote config is updated // This should return an error if the config is invalid SetConfig(config Runtime) error // GetConfig returns the current configuration of the check GetConfig() Runtime // Name returns the name of the check Name() string // Schema returns an openapi3.SchemaRef of the result type returned by the check Schema() (*openapi3.SchemaRef, error) // GetMetricCollectors allows the check to provide prometheus metric collectors GetMetricCollectors() []prometheus.Collector }
Check implementations are expected to perform specific monitoring tasks and report results.
type CheckBase ¶ added in v0.3.1
type CheckBase struct { // Mutex for thread-safe access to shared resources within the check implementation Mu sync.Mutex // Signal channel used to notify about shutdown of a check DoneChan chan struct{} }
CheckBase is a struct providing common fields used by implementations of the Check interface. It serves as a foundational structure that should be embedded in specific check implementations.
type CheckMock ¶ added in v0.1.2
type CheckMock struct { // GetConfigFunc mocks the GetConfig method. GetConfigFunc func() Runtime // GetMetricCollectorsFunc mocks the GetMetricCollectors method. GetMetricCollectorsFunc func() []prometheus.Collector // NameFunc mocks the Name method. NameFunc func() string // RunFunc mocks the Run method. RunFunc func(ctx context.Context, cResult chan ResultDTO) error // SchemaFunc mocks the Schema method. SchemaFunc func() (*openapi3.SchemaRef, error) // SetConfigFunc mocks the SetConfig method. SetConfigFunc func(config Runtime) error // ShutdownFunc mocks the Shutdown method. ShutdownFunc func() // contains filtered or unexported fields }
CheckMock is a mock implementation of Check.
func TestSomethingThatUsesCheck(t *testing.T) { // make and configure a mocked Check mockedCheck := &CheckMock{ GetConfigFunc: func() Runtime { panic("mock out the GetConfig method") }, GetMetricCollectorsFunc: func() []prometheus.Collector { panic("mock out the GetMetricCollectors method") }, NameFunc: func() string { panic("mock out the Name method") }, RunFunc: func(ctx context.Context, cResult chan ResultDTO) error { panic("mock out the Run method") }, SchemaFunc: func() (*openapi3.SchemaRef, error) { panic("mock out the Schema method") }, SetConfigFunc: func(config Runtime) error { panic("mock out the SetConfig method") }, ShutdownFunc: func() { panic("mock out the Shutdown method") }, } // use mockedCheck in code that requires Check // and then make assertions. }
func (*CheckMock) GetConfigCalls ¶ added in v0.3.1
func (mock *CheckMock) GetConfigCalls() []struct { }
GetConfigCalls gets all the calls that were made to GetConfig. Check the length with:
len(mockedCheck.GetConfigCalls())
func (*CheckMock) GetMetricCollectors ¶ added in v0.1.2
func (mock *CheckMock) GetMetricCollectors() []prometheus.Collector
GetMetricCollectors calls GetMetricCollectorsFunc.
func (*CheckMock) GetMetricCollectorsCalls ¶ added in v0.1.2
func (mock *CheckMock) GetMetricCollectorsCalls() []struct { }
GetMetricCollectorsCalls gets all the calls that were made to GetMetricCollectors. Check the length with:
len(mockedCheck.GetMetricCollectorsCalls())
func (*CheckMock) NameCalls ¶ added in v0.3.1
func (mock *CheckMock) NameCalls() []struct { }
NameCalls gets all the calls that were made to Name. Check the length with:
len(mockedCheck.NameCalls())
func (*CheckMock) RunCalls ¶ added in v0.1.2
RunCalls gets all the calls that were made to Run. Check the length with:
len(mockedCheck.RunCalls())
func (*CheckMock) SchemaCalls ¶ added in v0.1.2
func (mock *CheckMock) SchemaCalls() []struct { }
SchemaCalls gets all the calls that were made to Schema. Check the length with:
len(mockedCheck.SchemaCalls())
func (*CheckMock) SetConfigCalls ¶ added in v0.1.2
SetConfigCalls gets all the calls that were made to SetConfig. Check the length with:
len(mockedCheck.SetConfigCalls())
func (*CheckMock) Shutdown ¶ added in v0.1.2
func (mock *CheckMock) Shutdown()
Shutdown calls ShutdownFunc.
func (*CheckMock) ShutdownCalls ¶ added in v0.1.2
func (mock *CheckMock) ShutdownCalls() []struct { }
ShutdownCalls gets all the calls that were made to Shutdown. Check the length with:
len(mockedCheck.ShutdownCalls())
type ErrConfigMismatch ¶ added in v0.3.1
ErrConfigMismatch is returned when a configuration is of the wrong type
func (ErrConfigMismatch) Error ¶ added in v0.3.1
func (e ErrConfigMismatch) Error() string
type ErrInvalidConfig ¶
ErrInvalidConfig is returned when a configuration is invalid
func (ErrInvalidConfig) Error ¶ added in v0.3.1
func (e ErrInvalidConfig) Error() string
type GlobalTarget ¶ added in v0.2.0
GlobalTarget includes the basic information regarding other Sparrow instances, which this Sparrow can communicate with.
type Result ¶
type Result struct { // Data contains performance metrics about the check run Data any `json:"data"` // Timestamp is the UTC time the check was run Timestamp time.Time `json:"timestamp"` }
Result encapsulates the outcome of a check run.