• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

snivilised / extendio / 5951900512

23 Aug 2023 01:19PM UTC coverage: 90.747% (-0.4%) from 91.118%
5951900512

push

github

plastikfan
feat(nav): use context for concurrent navigation (#292)

109 of 109 new or added lines in 8 files covered. (100.0%)

2295 of 2529 relevant lines covered (90.75%)

4.23 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

79.75
/xfs/nav/resume-strategy-fastward.go
1
package nav
2

3
import (
4
        "fmt"
5

6
        "github.com/snivilised/extendio/internal/log"
7
)
8

9
type fastwardListener struct {
10
        target string
11
}
12

13
func (l *fastwardListener) Description() string {
×
14
        return fmt.Sprintf(">>> fast forwarding >>> to: '%v'", l.target)
×
15
}
×
16

17
func (l *fastwardListener) Validate() {}
×
18

19
func (l *fastwardListener) Source() string {
×
20
        return l.target
×
21
}
×
22

23
func (l *fastwardListener) IsMatch(item *TraverseItem) bool {
4✔
24
        return item.Path == l.target
4✔
25
}
4✔
26

27
func (l *fastwardListener) IsApplicable(_ *TraverseItem) bool {
×
28
        return true
×
29
}
×
30

31
func (l *fastwardListener) Scope() FilterScopeBiEnum {
×
32
        return ScopeAllEn
×
33
}
×
34

35
type fastwardStrategy struct {
36
        baseStrategy
37
        client struct {
38
                state ListeningState
39
        }
40
        overrideInfo *overrideListenerInfo
41
}
42

43
func (s *fastwardStrategy) init(params *strategyInitParams) {
4✔
44
        s.nc.logger().Info("fastward resume", log.String("path", params.ps.Active.Root))
4✔
45
        // this is the start we revert back to when we get back to the resume point
4✔
46
        //
4✔
47
        s.client.state = params.ps.Active.Listen
4✔
48

4✔
49
        pci := &preserveClientInfo{
4✔
50
                triggers:   params.triggers,
4✔
51
                behaviours: s.o.Store.Behaviours.Listen,
4✔
52
        }
4✔
53

4✔
54
        s.overrideInfo = &overrideListenerInfo{
4✔
55
                client: pci,
4✔
56
                override: &overrideClientInfo{
4✔
57
                        triggers: &ListenTriggers{
4✔
58
                                Stop: &fastwardListener{
4✔
59
                                        target: s.ps.Active.NodePath,
4✔
60
                                },
4✔
61
                        },
4✔
62
                },
4✔
63
                ps: params.ps,
4✔
64
        }
4✔
65

4✔
66
        s.attach(&resumeAttachParams{
4✔
67
                o:        s.o,
4✔
68
                frame:    params.frame,
4✔
69
                triggers: s.overrideInfo.override.triggers,
4✔
70
        })
4✔
71
}
4✔
72

73
func (s *fastwardStrategy) attach(params *resumeAttachParams) {
4✔
74
        // for the resume scenario, we don't have to attach a new decorator, rather the
4✔
75
        // change of state accounts for the new behaviour. frame.attach is only used
4✔
76
        // to setup the navigation-listener. resume sits atop the listener but a new item
4✔
77
        // still has to be pushed onto the resumeStack.
4✔
78
        //
4✔
79
        params.frame.listener.triggers = params.triggers
4✔
80
        params.frame.listener.resumeStack.Push(params.triggers)
4✔
81
        params.frame.listener.transition(ListenFastward)
4✔
82
        params.frame.notifiers.mute(notificationAllEn)
4✔
83
}
4✔
84

85
func (s *fastwardStrategy) detach(frame *navigationFrame) {
4✔
86
        frame.listener.dispose()
4✔
87

4✔
88
        // now restore the client state (preserveClientInfo)
4✔
89
        //
4✔
90
        s.o.Store.Behaviours.Listen = s.overrideInfo.client.behaviours
4✔
91

4✔
92
        frame.notifiers.mute(notificationAllEn, false)
4✔
93

4✔
94
        if s.ps.Active.Listen == ListenFastward {
4✔
95
                panic(NewInvalidResumeStateTransitionNativeError("ListenFastward"))
×
96
        }
97

98
        frame.listener.transition(s.ps.Active.Listen)
4✔
99
}
100

101
func (s *fastwardStrategy) resume(info *strategyResumeInfo) (*TraverseResult, error) {
4✔
102
        resumeAt := info.ps.Active.NodePath
4✔
103
        s.nc.logger().Info("fastward resume",
4✔
104
                log.String("root-path", info.ps.Active.Root),
4✔
105
                log.String("resume-at-path", resumeAt),
4✔
106
        )
4✔
107

4✔
108
        if info.ai != nil {
4✔
109
                s.ensync(info.ai)
×
110
        }
×
111

112
        // fast-forward doesn't need to restore the entire state, eg, the
113
        // Depth can begin as per usual, without being restored.
114
        //
115
        return info.nc.walk(info.ps.Active.Root)
4✔
116
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc