-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
94 lines (85 loc) · 3.38 KB
/
main.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2023 Steadybit GmbH
package main
import (
_ "github.com/KimMachineGun/automemlimit" // By default, it sets `GOMEMLIMIT` to 90% of cgroup's memory limit.
"github.com/rs/zerolog"
"github.com/steadybit/action-kit/go/action_kit_api/v2"
"github.com/steadybit/action-kit/go/action_kit_sdk"
"github.com/steadybit/discovery-kit/go/discovery_kit_api"
"github.com/steadybit/discovery-kit/go/discovery_kit_sdk"
"github.com/steadybit/event-kit/go/event_kit_api"
"github.com/steadybit/extension-datadog/config"
"github.com/steadybit/extension-datadog/extevents"
"github.com/steadybit/extension-datadog/extmonitor"
"github.com/steadybit/extension-kit/extbuild"
"github.com/steadybit/extension-kit/exthealth"
"github.com/steadybit/extension-kit/exthttp"
"github.com/steadybit/extension-kit/extlogging"
"github.com/steadybit/extension-kit/extruntime"
"github.com/steadybit/extension-kit/extsignals"
_ "go.uber.org/automaxprocs" // Importing automaxprocs automatically adjusts GOMAXPROCS.
_ "net/http/pprof" //allow pprof
)
func main() {
extlogging.InitZeroLog()
extbuild.PrintBuildInformation()
extruntime.LogRuntimeInformation(zerolog.DebugLevel)
exthealth.SetReady(false)
exthealth.StartProbes(8091)
config.ParseConfiguration()
config.ValidateConfiguration()
exthttp.RegisterHttpHandler("/", exthttp.GetterAsHandler(getExtensionList))
discovery_kit_sdk.Register(extmonitor.NewMonitorDiscovery())
action_kit_sdk.RegisterAction(extmonitor.NewMonitorStatusCheckAction())
action_kit_sdk.RegisterAction(extmonitor.NewMonitorDowntimeAction())
extevents.RegisterEventListenerHandlers()
action_kit_sdk.RegisterCoverageEndpoints()
extsignals.ActivateSignalHandlers()
exthealth.SetReady(true)
exthttp.Listen(exthttp.ListenOpts{
Port: 8090,
})
}
// ExtensionListResponse exists to merge the possible root path responses supported by the
// various extension kits. In this case, the response for ActionKit, DiscoveryKit and EventKit.
type ExtensionListResponse struct {
action_kit_api.ActionList `json:",inline"`
discovery_kit_api.DiscoveryList `json:",inline"`
event_kit_api.EventListenerList `json:",inline"`
}
func getExtensionList() ExtensionListResponse {
return ExtensionListResponse{
ActionList: action_kit_sdk.GetActionList(),
DiscoveryList: discovery_kit_sdk.GetDiscoveryList(),
EventListenerList: event_kit_api.EventListenerList{
EventListeners: []event_kit_api.EventListener{
{
Method: "POST",
Path: "/events/experiment-started",
ListenTo: []string{"experiment.execution.created"},
},
{
Method: "POST",
Path: "/events/experiment-completed",
ListenTo: []string{"experiment.execution.completed", "experiment.execution.failed", "experiment.execution.canceled", "experiment.execution.errored"},
},
{
Method: "POST",
Path: "/events/experiment-step-started",
ListenTo: []string{"experiment.execution.step-started"},
},
{
Method: "POST",
Path: "/events/experiment-target-started",
ListenTo: []string{"experiment.execution.target-started"},
},
{
Method: "POST",
Path: "/events/experiment-target-completed",
ListenTo: []string{"experiment.execution.target-completed", "experiment.execution.target-canceled", "experiment.execution.target-errored", "experiment.execution.target-failed"},
},
},
},
}
}