Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aos
GitHub Repository: aos/grafana-agent
Path: blob/main/pkg/integrations/v2/utils.go
5302 views
1
package integrations
2
3
import (
4
"context"
5
"net/http"
6
7
"github.com/grafana/agent/pkg/util"
8
)
9
10
// FuncIntegration is a function that implements Integration.
11
type FuncIntegration func(ctx context.Context) error
12
13
// RunIntegration implements Integration.
14
func (fi FuncIntegration) RunIntegration(ctx context.Context) error { return fi(ctx) }
15
16
// Handler implements HTTPIntegration
17
func (fi FuncIntegration) Handler(prefix string) (http.Handler, error) {
18
return nil, nil
19
}
20
21
// NoOpIntegration is an Integration that does nothing.
22
var NoOpIntegration = FuncIntegration(func(ctx context.Context) error {
23
<-ctx.Done()
24
return nil
25
})
26
27
// CompareConfigs will return true if a and b are equal. If neither a nor b
28
// implements ComparableConfig, then configs are compared by marshaling to YAML
29
// and comparing the results.
30
func CompareConfigs(a, b Config) bool {
31
if a, ok := a.(ComparableConfig); ok {
32
return a.ConfigEquals(b)
33
}
34
if b, ok := b.(ComparableConfig); ok {
35
return b.ConfigEquals(a)
36
}
37
return util.CompareYAML(a, b)
38
}
39
40