forked from VolantMQ/volantmq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tree.go
69 lines (57 loc) · 1.48 KB
/
tree.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
package systree
import (
"github.com/VolantMQ/volantmq/types"
)
type impl struct {
server server
metrics metric
topics topicStat
subscriptions subscriptionsStat
clients clients
sessions sessions
}
// NewTree allocate systree provider
func NewTree(base string) (Provider, []types.RetainObject, []DynamicValue, error) {
var retains []types.RetainObject
var staticRetains []types.RetainObject
tr := &impl{
newServer(base, &retains, &staticRetains),
newMetric(base, &retains),
newStatTopic(base+"/stats", &retains),
newStatSubscription(base+"/stats", &retains),
newClients(base, &retains),
newSessions(base, &retains),
}
var dynUpdates []DynamicValue
for _, d := range retains {
v := d.(DynamicValue)
dynUpdates = append(dynUpdates, v)
}
retains = append(retains, staticRetains...)
return tr, retains, dynUpdates, nil
}
// SetCallbacks
func (t *impl) SetCallbacks(cb types.TopicMessenger) {
t.clients.topicsManager = cb
t.sessions.topicsManager = cb
}
// Sessions get sessions stat provider
func (t *impl) Sessions() Sessions {
return &t.sessions
}
// Clients get clients stat provider
func (t *impl) Clients() Clients {
return &t.clients
}
// Topics get topics stat provider
func (t *impl) Topics() TopicsStat {
return &t.topics
}
// Metric get metric provider
func (t *impl) Metric() Metric {
return &t.metrics
}
// Subscriptions get subscriptions stat provider
func (t *impl) Subscriptions() SubscriptionsStat {
return &t.subscriptions
}