Skip to content

Commit 968122a

Browse files
committed
ref(nav): adapt runner and session for concurrency (#320)"
ref(boost); update lint config for go 1.21 (#320) ref(nav): type renames (#320) ref(nav): add runner skelton (#320) ref(nav): add sync skelton (#320) ref(nav): partially define sync run (#320) ref(nav): add context to ensync (#320) ref(nav): migrate tests to use nav.New (#320)
1 parent bd054e1 commit 968122a

31 files changed

+672
-625
lines changed

.golangci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ linters:
2525
enable:
2626
- bodyclose
2727
# - deadcode
28-
- depguard
28+
# depguard needs to be reviewed properly and then configured, before
29+
# it can be re-enabled.
30+
# https://github.com/OpenPeeDeeP/depguard#example-configs
31+
# - depguard
2932
- dogsled
3033
# - dupl
3134
- errcheck

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/golangci/golangci-lint
3-
rev: v1.52.2
3+
rev: v1.54.2
44
hooks:
55
- id: golangci-lint
66

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"staticcheck",
6161
"structcheck",
6262
"stylecheck",
63+
"syncable",
6364
"Syncer",
6465
"teivah",
6566
"thelper",

xfs/nav/bootstrapper.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ func (d *nullDetacher) detach(_ *navigationFrame) {
1313

1414
type bootstrapper struct {
1515
o *TraverseOptions
16-
nc *navigatorController
17-
rc *resumeController
16+
nc *navigationController
17+
rc *resumeStrategyController
1818
detacher resumeDetacher
1919
}
2020

@@ -34,7 +34,10 @@ func (b *bootstrapper) init() {
3434
}
3535

3636
func (b *bootstrapper) initFilters() {
37-
b.o.Hooks.InitFilters(b.o, b.nc.frame)
37+
b.o.Hooks.InitFilters(
38+
b.o,
39+
b.nc.frame,
40+
)
3841
}
3942

4043
func (b *bootstrapper) initNotifiers() {
@@ -58,12 +61,14 @@ func (b *bootstrapper) initListener() {
5861
}
5962

6063
b.nc.frame.listener.makeStates(&listenStatesParams{
61-
o: b.o, frame: b.nc.frame,
64+
o: b.o,
65+
frame: b.nc.frame,
6266
detacher: b,
6367
})
6468

6569
b.nc.frame.listener.decorate(&listenStatesParams{
66-
triggers: &state.Listen, frame: b.nc.frame,
70+
triggers: &state.Listen,
71+
frame: b.nc.frame,
6772
})
6873
}
6974

xfs/nav/filter-glob_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,10 @@ var _ = Describe("FilterGlob", Ordered, func() {
7575
},
7676
}
7777
}
78-
session := nav.PrimarySession{
79-
Path: path,
80-
OptionFn: optionFn,
81-
}
82-
result, _ := session.Init().Run()
78+
result, err := nav.New().Primary(&nav.Prime{
79+
Path: path,
80+
OptionsFn: optionFn,
81+
}).Run()
8382

8483
if entry.mandatory != nil {
8584
for _, name := range entry.mandatory {
@@ -95,6 +94,7 @@ var _ = Describe("FilterGlob", Ordered, func() {
9594
}
9695
}
9796

97+
Expect(err).Error().To(BeNil())
9898
Expect(result.Metrics.Count(nav.MetricNoFilesInvokedEn)).To(Equal(entry.expectedNoOf.files),
9999
"Incorrect no of files")
100100
Expect(result.Metrics.Count(nav.MetricNoFoldersInvokedEn)).To(Equal(entry.expectedNoOf.folders),
@@ -235,11 +235,11 @@ var _ = Describe("FilterGlob", Ordered, func() {
235235
},
236236
}
237237
}
238-
session := nav.PrimarySession{
239-
Path: path,
240-
OptionFn: optionFn,
241-
}
242-
result, _ := session.Init().Run()
238+
239+
result, _ := nav.New().Primary(&nav.Prime{
240+
Path: path,
241+
OptionsFn: optionFn,
242+
}).Run()
243243

244244
if entry.mandatory != nil {
245245
for _, name := range entry.mandatory {

xfs/nav/filter-regex_test.go

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,10 @@ var _ = Describe("FilterRegex", Ordered, func() {
7676
},
7777
}
7878
}
79-
session := nav.PrimarySession{
80-
Path: path,
81-
OptionFn: optionFn,
82-
}
83-
result, _ := session.Init().Run()
79+
result, err := nav.New().Primary(&nav.Prime{
80+
Path: path,
81+
OptionsFn: optionFn,
82+
}).Run()
8483

8584
if entry.mandatory != nil {
8685
for _, name := range entry.mandatory {
@@ -96,6 +95,7 @@ var _ = Describe("FilterRegex", Ordered, func() {
9695
}
9796
}
9897

98+
Expect(err).Error().To(BeNil())
9999
Expect(result.Metrics.Count(nav.MetricNoFilesInvokedEn)).To(Equal(entry.expectedNoOf.files),
100100
"Incorrect no of files")
101101
Expect(result.Metrics.Count(nav.MetricNoFoldersInvokedEn)).To(Equal(entry.expectedNoOf.folders),
@@ -278,11 +278,11 @@ var _ = Describe("FilterRegex", Ordered, func() {
278278
},
279279
}
280280
}
281-
session := nav.PrimarySession{
282-
Path: path,
283-
OptionFn: optionFn,
284-
}
285-
result, _ := session.Init().Run()
281+
282+
result, _ := nav.New().Primary(&nav.Prime{
283+
Path: path,
284+
OptionsFn: optionFn,
285+
}).Run()
286286

287287
if entry.mandatory != nil {
288288
for _, name := range entry.mandatory {
@@ -364,6 +364,7 @@ var _ = Describe("FilterRegex", Ordered, func() {
364364
pe := recover()
365365
if entry.errorContains != "" {
366366
if err, ok := pe.(error); ok {
367+
// nil pointer dereference
367368
Expect(strings.Contains(err.Error(), entry.errorContains)).To(BeTrue())
368369
}
369370
} else {
@@ -392,11 +393,11 @@ var _ = Describe("FilterRegex", Ordered, func() {
392393
},
393394
}
394395
}
395-
session := nav.PrimarySession{
396-
Path: path,
397-
OptionFn: optionFn,
398-
}
399-
_, _ = session.Init().Run()
396+
397+
_, _ = nav.New().Primary(&nav.Prime{
398+
Path: path,
399+
OptionsFn: optionFn,
400+
}).Run()
400401

401402
Fail(fmt.Sprintf("❌ expected panic due to '%v'", entry.name))
402403
},
@@ -448,11 +449,11 @@ var _ = Describe("FilterRegex", Ordered, func() {
448449
},
449450
}
450451
}
451-
session := nav.PrimarySession{
452-
Path: path,
453-
OptionFn: optionFn,
454-
}
455-
_, _ = session.Init().Run()
452+
453+
_, _ = nav.New().Primary(&nav.Prime{
454+
Path: path,
455+
OptionsFn: optionFn,
456+
}).Run()
456457

457458
Fail(fmt.Sprintf("❌ expected panic due to '%v'", entry.name))
458459
},

xfs/nav/marshal-state_test.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,14 @@ var _ = Describe("MarshalOptions", Ordered, func() {
6868
},
6969
}
7070
}
71-
session := &nav.PrimarySession{
72-
Path: path,
73-
OptionFn: optionFn,
74-
}
7571

76-
_, _ = session.Init().Run()
77-
err := session.Save(toJSONPath)
72+
runner := nav.New().Primary(&nav.Prime{
73+
Path: path,
74+
OptionsFn: optionFn,
75+
})
76+
77+
_, _ = runner.Run()
78+
err := runner.Save(toJSONPath)
7879

7980
Expect(err).To(BeNil())
8081
})
@@ -104,13 +105,13 @@ var _ = Describe("MarshalOptions", Ordered, func() {
104105
},
105106
}
106107
}
107-
session := &nav.PrimarySession{
108-
Path: path,
109-
OptionFn: optionFn,
110-
}
108+
runner := nav.New().Primary(&nav.Prime{
109+
Path: path,
110+
OptionsFn: optionFn,
111+
})
111112

112-
_, _ = session.Init().Run()
113-
_ = session.Save(toJSONPath)
113+
_, _ = runner.Run()
114+
_ = runner.Save(toJSONPath)
114115

115116
Fail(fmt.Sprintf("❌ expected panic due to %v", entry.errorContains))
116117
},

xfs/nav/navigation-agent.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ func (agentFactory) new(params *agentFactoryParams) *navigationAgent {
2828
}
2929

3030
type navigationAgent struct {
31-
doInvoke utils.RoProp[bool]
32-
o *TraverseOptions
33-
deFactory directoryEntriesFactory
34-
handler fileSystemErrorHandler
31+
doInvoke utils.RoProp[bool]
32+
o *TraverseOptions
33+
handler fileSystemErrorHandler
3534
}
3635

3736
type agentTopParams struct {
@@ -81,7 +80,8 @@ func (a *navigationAgent) read(path string, order DirectoryEntryOrderEnum) (*Dir
8180
//
8281
entries, err := a.o.Hooks.ReadDirectory(path)
8382

84-
de := a.deFactory.new(&directoryEntriesFactoryParams{
83+
deFactory := directoryEntriesFactory{}
84+
de := deFactory.new(&directoryEntriesFactoryParams{
8585
o: a.o,
8686
order: order,
8787
entries: &entries,

xfs/nav/navigation-async-defs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type TraverseItemOutputStreamR = boost.OutputStreamR[TraverseOutput]
2525
type TraverseItemOutputStreamW = boost.OutputStreamW[TraverseOutput]
2626

2727
type AsyncInfo struct {
28-
Context context.Context
28+
Context context.Context // this will be retired, instead passed into Run
2929

3030
// this doesn't seem right, the client shouldn't have to specify
3131
// the routine name for the navigator; should be a readonly prop

0 commit comments

Comments
 (0)