-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
component.go
58 lines (46 loc) · 1.65 KB
/
component.go
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2023-present Datadog, Inc.
// Package api implements the internal Agent API which exposes endpoints such as config, flare or status
package api
import (
"net"
"net/http"
"github.com/DataDog/datadog-agent/pkg/aggregator/sender"
"go.uber.org/fx"
)
// team: agent-shared-components
// TODO(components):
// * Lifecycle can't be used atm because:
// - logsAgent and remoteconfig.Service are modified in `startAgent` in the run subcommand
// - Same for workloadmeta and senderManager in `execJmxCommand` in the jmx subcommand
// Component is the component type.
type Component interface {
StartServer(
senderManager sender.DiagnoseSenderManager,
) error
StopServer()
ServerAddress() *net.TCPAddr
}
// EndpointProvider is an interface to register api endpoints
type EndpointProvider struct {
HandlerFunc http.HandlerFunc
Methods []string
Route string
}
// AgentEndpointProvider is the provider for registering endpoints to the internal agent api server
type AgentEndpointProvider struct {
fx.Out
Provider EndpointProvider `group:"agent_endpoint"`
}
// NewAgentEndpointProvider returns a AgentEndpointProvider to register the endpoint provided to the internal agent api server
func NewAgentEndpointProvider(handlerFunc http.HandlerFunc, route string, methods ...string) AgentEndpointProvider {
return AgentEndpointProvider{
Provider: EndpointProvider{
HandlerFunc: handlerFunc,
Route: route,
Methods: methods,
},
}
}