Skip to content

Commit

Permalink
ref(nav): adapt runner and session for concurrency (#320)"
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
plastikfan committed Oct 6, 2023
1 parent bd054e1 commit 61acf7c
Show file tree
Hide file tree
Showing 31 changed files with 672 additions and 625 deletions.
5 changes: 4 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ linters:
enable:
- bodyclose
# - deadcode
- depguard
# depguard needs to be reviewed properly and then configured, before
# it can be re-enabled.
# https://github.com/OpenPeeDeeP/depguard#example-configs
# - depguard
- dogsled
# - dupl
- errcheck
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/golangci/golangci-lint
rev: v1.52.2
rev: v1.54.2
hooks:
- id: golangci-lint

Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"staticcheck",
"structcheck",
"stylecheck",
"syncable",
"Syncer",
"teivah",
"thelper",
Expand Down
15 changes: 10 additions & 5 deletions xfs/nav/bootstrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ func (d *nullDetacher) detach(_ *navigationFrame) {

type bootstrapper struct {
o *TraverseOptions
nc *navigatorController
rc *resumeController
nc *navigationController
rc *resumeStrategyController
detacher resumeDetacher
}

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

func (b *bootstrapper) initFilters() {
b.o.Hooks.InitFilters(b.o, b.nc.frame)
b.o.Hooks.InitFilters(
b.o,
b.nc.frame,
)
}

func (b *bootstrapper) initNotifiers() {
Expand All @@ -58,12 +61,14 @@ func (b *bootstrapper) initListener() {
}

b.nc.frame.listener.makeStates(&listenStatesParams{
o: b.o, frame: b.nc.frame,
o: b.o,
frame: b.nc.frame,
detacher: b,
})

b.nc.frame.listener.decorate(&listenStatesParams{
triggers: &state.Listen, frame: b.nc.frame,
triggers: &state.Listen,
frame: b.nc.frame,
})
}

Expand Down
20 changes: 10 additions & 10 deletions xfs/nav/filter-glob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,10 @@ var _ = Describe("FilterGlob", Ordered, func() {
},
}
}
session := nav.PrimarySession{
Path: path,
OptionFn: optionFn,
}
result, _ := session.Init().Run()
result, err := nav.New().Primary(&nav.Prime{
Path: path,
OptionsFn: optionFn,
}).Run()

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

Expect(err).Error().To(BeNil())
Expect(result.Metrics.Count(nav.MetricNoFilesInvokedEn)).To(Equal(entry.expectedNoOf.files),
"Incorrect no of files")
Expect(result.Metrics.Count(nav.MetricNoFoldersInvokedEn)).To(Equal(entry.expectedNoOf.folders),
Expand Down Expand Up @@ -235,11 +235,11 @@ var _ = Describe("FilterGlob", Ordered, func() {
},
}
}
session := nav.PrimarySession{
Path: path,
OptionFn: optionFn,
}
result, _ := session.Init().Run()

result, _ := nav.New().Primary(&nav.Prime{
Path: path,
OptionsFn: optionFn,
}).Run()

if entry.mandatory != nil {
for _, name := range entry.mandatory {
Expand Down
41 changes: 21 additions & 20 deletions xfs/nav/filter-regex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,10 @@ var _ = Describe("FilterRegex", Ordered, func() {
},
}
}
session := nav.PrimarySession{
Path: path,
OptionFn: optionFn,
}
result, _ := session.Init().Run()
result, err := nav.New().Primary(&nav.Prime{
Path: path,
OptionsFn: optionFn,
}).Run()

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

Expect(err).Error().To(BeNil())
Expect(result.Metrics.Count(nav.MetricNoFilesInvokedEn)).To(Equal(entry.expectedNoOf.files),
"Incorrect no of files")
Expect(result.Metrics.Count(nav.MetricNoFoldersInvokedEn)).To(Equal(entry.expectedNoOf.folders),
Expand Down Expand Up @@ -278,11 +278,11 @@ var _ = Describe("FilterRegex", Ordered, func() {
},
}
}
session := nav.PrimarySession{
Path: path,
OptionFn: optionFn,
}
result, _ := session.Init().Run()

result, _ := nav.New().Primary(&nav.Prime{
Path: path,
OptionsFn: optionFn,
}).Run()

if entry.mandatory != nil {
for _, name := range entry.mandatory {
Expand Down Expand Up @@ -364,6 +364,7 @@ var _ = Describe("FilterRegex", Ordered, func() {
pe := recover()
if entry.errorContains != "" {
if err, ok := pe.(error); ok {
// nil pointer dereference
Expect(strings.Contains(err.Error(), entry.errorContains)).To(BeTrue())
}
} else {
Expand Down Expand Up @@ -392,11 +393,11 @@ var _ = Describe("FilterRegex", Ordered, func() {
},
}
}
session := nav.PrimarySession{
Path: path,
OptionFn: optionFn,
}
_, _ = session.Init().Run()

_, _ = nav.New().Primary(&nav.Prime{
Path: path,
OptionsFn: optionFn,
}).Run()

Fail(fmt.Sprintf("❌ expected panic due to '%v'", entry.name))
},
Expand Down Expand Up @@ -448,11 +449,11 @@ var _ = Describe("FilterRegex", Ordered, func() {
},
}
}
session := nav.PrimarySession{
Path: path,
OptionFn: optionFn,
}
_, _ = session.Init().Run()

_, _ = nav.New().Primary(&nav.Prime{
Path: path,
OptionsFn: optionFn,
}).Run()

Fail(fmt.Sprintf("❌ expected panic due to '%v'", entry.name))
},
Expand Down
25 changes: 13 additions & 12 deletions xfs/nav/marshal-state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,14 @@ var _ = Describe("MarshalOptions", Ordered, func() {
},
}
}
session := &nav.PrimarySession{
Path: path,
OptionFn: optionFn,
}

_, _ = session.Init().Run()
err := session.Save(toJSONPath)
runner := nav.New().Primary(&nav.Prime{
Path: path,
OptionsFn: optionFn,
})

_, _ = runner.Run()
err := runner.Save(toJSONPath)

Expect(err).To(BeNil())
})
Expand Down Expand Up @@ -104,13 +105,13 @@ var _ = Describe("MarshalOptions", Ordered, func() {
},
}
}
session := &nav.PrimarySession{
Path: path,
OptionFn: optionFn,
}
runner := nav.New().Primary(&nav.Prime{
Path: path,
OptionsFn: optionFn,
})

_, _ = session.Init().Run()
_ = session.Save(toJSONPath)
_, _ = runner.Run()
_ = runner.Save(toJSONPath)

Fail(fmt.Sprintf("❌ expected panic due to %v", entry.errorContains))
},
Expand Down
10 changes: 5 additions & 5 deletions xfs/nav/navigation-agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ func (agentFactory) new(params *agentFactoryParams) *navigationAgent {
}

type navigationAgent struct {
doInvoke utils.RoProp[bool]
o *TraverseOptions
deFactory directoryEntriesFactory
handler fileSystemErrorHandler
doInvoke utils.RoProp[bool]
o *TraverseOptions
handler fileSystemErrorHandler
}

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

de := a.deFactory.new(&directoryEntriesFactoryParams{
deFactory := directoryEntriesFactory{}
de := deFactory.new(&directoryEntriesFactoryParams{
o: a.o,
order: order,
entries: &entries,
Expand Down
2 changes: 1 addition & 1 deletion xfs/nav/navigation-async-defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type TraverseItemOutputStreamR = boost.OutputStreamR[TraverseOutput]
type TraverseItemOutputStreamW = boost.OutputStreamW[TraverseOutput]

type AsyncInfo struct {
Context context.Context
Context context.Context // this will be retired, instead passed into Run

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

0 comments on commit 61acf7c

Please sign in to comment.