-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrapper.go
109 lines (87 loc) 路 2.06 KB
/
bootstrapper.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package nav
import (
"github.com/snivilised/extendio/collections"
)
type nullDetacher struct{}
func (d *nullDetacher) detach(_ *navigationFrame) {
}
type bootstrapper struct {
o *TraverseOptions
nc *navigationController
rc *resumeStrategyController
detacher resumeDetacher
}
func (b *bootstrapper) init() {
b.detacher = &nullDetacher{}
b.nc.frame = b.nc.makeFrame()
b.initFilters()
b.initNotifiers()
b.initListener()
b.nc.init()
b.nc.ns = &NavigationState{
Filters: b.nc.frame.filters,
Root: &b.nc.frame.root,
Logger: b.o.Monitor.Log,
}
}
func (b *bootstrapper) initFilters() {
b.o.Hooks.InitFilters(
b.o,
b.nc.frame,
)
}
func (b *bootstrapper) initNotifiers() {
if b.o.Notify.OnStart == nil {
b.o.Notify.OnStart = func(_ string) {}
}
if b.o.Notify.OnStop == nil {
b.o.Notify.OnStop = func(_ string) {}
}
b.nc.frame.notifiers.init(&b.o.Notify)
}
func (b *bootstrapper) initListener() {
state := backfill(&b.o.Store.ListenDefs)
b.nc.frame.listener = &navigationListener{
state: state.initialState,
resumeStack: collections.NewStack[*ListenTriggers](),
}
b.nc.frame.listener.makeStates(&listenStatesParams{
o: b.o,
frame: b.nc.frame,
detacher: b,
})
b.nc.frame.listener.decorate(&listenStatesParams{
triggers: &state.Listen,
frame: b.nc.frame,
})
}
type preserveClientInfo struct {
triggers *ListenTriggers
behaviours ListenBehaviour
}
type overrideClientInfo struct {
triggers *ListenTriggers
}
type overrideListenerInfo struct {
client *preserveClientInfo
override *overrideClientInfo
ps *persistState
}
func (b *bootstrapper) initResume(ps *persistState) {
if b.rc == nil {
err := NewResumeControllerNotSetNativeError("bootstrapper.initResume")
b.nc.impl.logger().Error(err.Error())
panic(err)
}
strategyParams := &strategyInitParams{
ps: ps,
frame: b.nc.frame,
rc: b.rc,
}
b.nc.frame.metrics.load(ps.Active)
b.rc.strategy.init(strategyParams)
b.detacher = b.rc
}
func (b *bootstrapper) detach(_ *navigationFrame) {
b.detacher.detach(b.nc.frame)
}