-
Notifications
You must be signed in to change notification settings - Fork 53
/
broker.go
57 lines (50 loc) · 1.88 KB
/
broker.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
package storage
import (
"github.com/rancher/opni/pkg/alerting/drivers/routing"
"github.com/rancher/opni/pkg/alerting/interfaces"
"github.com/rancher/opni/pkg/alerting/storage/jetstream"
"github.com/rancher/opni/pkg/alerting/storage/mem"
"github.com/rancher/opni/pkg/alerting/storage/opts"
alertingv1 "github.com/rancher/opni/pkg/apis/alerting/v1"
)
var _ RouterStorage = (*jetstream.JetstreamRouterStore[routing.OpniRouting])(nil)
var _ AlertingStorage[interfaces.AlertingSecret] = (*jetstream.JetStreamAlertingStorage[interfaces.AlertingSecret])(nil)
var _ AlertingStateCache[*alertingv1.CachedState] = (*jetstream.JetStreamAlertingStateCache)(nil)
var _ AlertingIncidentTracker[*alertingv1.IncidentIntervals] = (*jetstream.JetStreamAlertingIncidentTracker)(nil)
var _ AlertingStorage[interfaces.AlertingSecret] = (*jetstream.JetStreamAlertingStorage[interfaces.AlertingSecret])(nil)
var _ RouterStorage = (*mem.InMemoryRouterStore)(nil)
type CompositeAlertingBroker struct {
opts.ClientSetOptions
*CompositeAlertingClientSet
}
func NewCompositeAlertingBroker(options opts.ClientSetOptions) *CompositeAlertingBroker {
return &CompositeAlertingBroker{
ClientSetOptions: options,
CompositeAlertingClientSet: &CompositeAlertingClientSet{
hashes: make(map[string]string),
Logger: options.Logger,
},
}
}
var _ AlertingClientSet = (*CompositeAlertingBroker)(nil)
var _ AlertingStoreBroker = (*CompositeAlertingBroker)(nil)
func (c *CompositeAlertingBroker) Use(store any) {
if cs, ok := store.(ConditionStorage); ok {
c.conds = cs
}
if es, ok := store.(EndpointStorage); ok {
c.endps = es
}
if rs, ok := store.(RouterStorage); ok {
c.routers = rs
}
if ss, ok := store.(StateStorage); ok {
c.states = ss
}
if is, ok := store.(IncidentStorage); ok {
c.incidents = is
}
}
func (c *CompositeAlertingBroker) NewClientSet() AlertingClientSet {
return c.CompositeAlertingClientSet
}