-
Notifications
You must be signed in to change notification settings - Fork 25
/
agent.go
71 lines (65 loc) · 2.05 KB
/
agent.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
59
60
61
62
63
64
65
66
67
68
69
70
71
//go:generate swagger generate spec --scan-models --include="github.com/fluxninja*" --include-tag=common-configuration --include-tag=agent-configuration -o ../../docs/gen/config/agent/config-swagger.yaml
//go:generate go run ../../docs/tools/swagger/process-go-tags.go ../../docs/gen/config/agent/config-swagger.yaml
// Package main Agent
//
// Aperture Agent
//
// BasePath: /aperture-agent
//
// swagger:meta
package main
import (
"github.com/jonboulle/clockwork"
"go.uber.org/fx"
"github.com/fluxninja/aperture/cmd/aperture-agent/agent"
"github.com/fluxninja/aperture/pkg/agentfunctions"
"github.com/fluxninja/aperture/pkg/agentinfo"
"github.com/fluxninja/aperture/pkg/discovery"
"github.com/fluxninja/aperture/pkg/distcache"
"github.com/fluxninja/aperture/pkg/entitycache"
"github.com/fluxninja/aperture/pkg/etcd/election"
"github.com/fluxninja/aperture/pkg/k8s"
"github.com/fluxninja/aperture/pkg/log"
"github.com/fluxninja/aperture/pkg/otelcollector"
"github.com/fluxninja/aperture/pkg/peers"
"github.com/fluxninja/aperture/pkg/platform"
"github.com/fluxninja/aperture/pkg/policies/flowcontrol"
"github.com/fluxninja/aperture/pkg/policies/infra"
"github.com/fluxninja/aperture/pkg/prometheus"
"github.com/fluxninja/aperture/pkg/rpc"
)
func main() {
app := platform.New(
platform.Config{}.Module(),
prometheus.Module(),
k8s.Module(),
peers.Constructor{}.Module(),
fx.Provide(
agentinfo.ProvideAgentInfo,
clockwork.NewRealClock,
agent.ProvidePeersPrefix,
),
fx.Invoke(
agent.AddAgentInfoAttribute,
),
entitycache.Module(),
distcache.Module(),
flowcontrol.Module(),
infra.Module(),
otelcollector.Module(),
agent.ModuleForAgentOTEL(),
discovery.Module(),
election.Module(),
rpc.ClientModule,
agentfunctions.Module,
)
if err := app.Err(); err != nil {
visualize, viserr := fx.VisualizeError(err)
if viserr != nil {
log.Panic().Err(viserr).Msgf("Failed to visualize fx error: %s", viserr)
}
log.Panic().Err(err).Msg("fx.New failed: " + visualize)
}
log.Info().Msg("aperture-agent app created")
platform.Run(app)
}