diff --git a/xfs/nav/filter-glob_test.go b/xfs/nav/filter-glob_test.go index 4d13f91..b26a11b 100644 --- a/xfs/nav/filter-glob_test.go +++ b/xfs/nav/filter-glob_test.go @@ -55,7 +55,7 @@ var _ = Describe("FilterGlob", Ordered, func() { o.Store.Subscription = entry.subscription o.Store.FilterDefs = filterDefs o.Store.DoExtend = true - o.Callback = nav.LabelledTraverseCallback{ + o.Callback = &nav.LabelledTraverseCallback{ Label: "test glob filter callback", Fn: func(item *nav.TraverseItem) error { GinkgoWriter.Printf( @@ -216,7 +216,7 @@ var _ = Describe("FilterGlob", Ordered, func() { o.Store.Subscription = entry.subscription o.Store.FilterDefs = filterDefs o.Store.DoExtend = true - o.Callback = nav.LabelledTraverseCallback{ + o.Callback = &nav.LabelledTraverseCallback{ Label: "test glob filter callback", Fn: func(item *nav.TraverseItem) error { actualNoChildren := len(item.Children) diff --git a/xfs/nav/filter-init.go b/xfs/nav/filter-init.go index d62e292..68ecc23 100644 --- a/xfs/nav/filter-init.go +++ b/xfs/nav/filter-init.go @@ -30,7 +30,7 @@ func InitFiltersHookFn(o *TraverseOptions, frame *navigationFrame) { return nil }, } - frame.raw = *decorator + frame.raw = decorator frame.decorate("init-current-filter ๐ŸŽ", decorator) } diff --git a/xfs/nav/filter-regex_test.go b/xfs/nav/filter-regex_test.go index 34e1943..7d6ad89 100644 --- a/xfs/nav/filter-regex_test.go +++ b/xfs/nav/filter-regex_test.go @@ -56,7 +56,7 @@ var _ = Describe("FilterRegex", Ordered, func() { o.Store.Subscription = entry.subscription o.Store.FilterDefs = filterDefs o.Store.DoExtend = true - o.Callback = nav.LabelledTraverseCallback{ + o.Callback = &nav.LabelledTraverseCallback{ Label: "test regex filter callback", Fn: func(item *nav.TraverseItem) error { GinkgoWriter.Printf( @@ -259,7 +259,7 @@ var _ = Describe("FilterRegex", Ordered, func() { o.Store.Subscription = entry.subscription o.Store.FilterDefs = filterDefs o.Store.DoExtend = true - o.Callback = nav.LabelledTraverseCallback{ + o.Callback = &nav.LabelledTraverseCallback{ Label: "test regex filter callback", Fn: func(item *nav.TraverseItem) error { actualNoChildren := len(item.Children) @@ -386,7 +386,7 @@ var _ = Describe("FilterRegex", Ordered, func() { o.Notify.OnBegin = begin("๐Ÿงฒ") o.Store.Subscription = nav.SubscribeFolders o.Store.FilterDefs = filterDefs - o.Callback = nav.LabelledTraverseCallback{ + o.Callback = &nav.LabelledTraverseCallback{ Label: "test regex filter callback", Fn: func(_ *nav.TraverseItem) error { return nil @@ -442,7 +442,7 @@ var _ = Describe("FilterRegex", Ordered, func() { o.Store.Subscription = nav.SubscribeFoldersWithFiles o.Store.FilterDefs = filterDefs o.Store.DoExtend = true - o.Callback = nav.LabelledTraverseCallback{ + o.Callback = &nav.LabelledTraverseCallback{ Label: "test regex filter callback", Fn: func(_ *nav.TraverseItem) error { return nil diff --git a/xfs/nav/helpers_test.go b/xfs/nav/helpers_test.go index 99f5d13..c149676 100644 --- a/xfs/nav/helpers_test.go +++ b/xfs/nav/helpers_test.go @@ -37,7 +37,7 @@ type naviTE struct { visit bool caseSensitive bool subscription nav.TraverseSubscription - callback nav.LabelledTraverseCallback + callback *nav.LabelledTraverseCallback mandatory []string prohibited []string expectedNoOf expectedNo @@ -150,10 +150,10 @@ func begin(em string) nav.BeginHandler { } } -func universalCallback(name string, extended bool) nav.LabelledTraverseCallback { +func universalCallback(name string, extended bool) *nav.LabelledTraverseCallback { ex := lo.Ternary(extended, "-EX", "") - return nav.LabelledTraverseCallback{ + return &nav.LabelledTraverseCallback{ Label: "test universal callback", Fn: func(item *nav.TraverseItem) error { depth := lo.TernaryF(extended, @@ -174,10 +174,10 @@ func universalCallback(name string, extended bool) nav.LabelledTraverseCallback } } -func universalCallbackNoAssert(name string, extended bool) nav.LabelledTraverseCallback { +func universalCallbackNoAssert(name string, extended bool) *nav.LabelledTraverseCallback { ex := lo.Ternary(extended, "-EX", "") - return nav.LabelledTraverseCallback{ + return &nav.LabelledTraverseCallback{ Label: "test universal callback", Fn: func(item *nav.TraverseItem) error { depth := lo.TernaryF(extended, @@ -193,10 +193,10 @@ func universalCallbackNoAssert(name string, extended bool) nav.LabelledTraverseC } } -func foldersCallback(name string, extended bool) nav.LabelledTraverseCallback { +func foldersCallback(name string, extended bool) *nav.LabelledTraverseCallback { ex := lo.Ternary(extended, "-EX", "") - return nav.LabelledTraverseCallback{ + return &nav.LabelledTraverseCallback{ Label: "folders callback", Fn: func(item *nav.TraverseItem) error { depth := lo.TernaryF(extended, @@ -221,10 +221,10 @@ func foldersCallback(name string, extended bool) nav.LabelledTraverseCallback { } } -func filesCallback(name string, extended bool) nav.LabelledTraverseCallback { +func filesCallback(name string, extended bool) *nav.LabelledTraverseCallback { ex := lo.Ternary(extended, "-EX", "") - return nav.LabelledTraverseCallback{ + return &nav.LabelledTraverseCallback{ Label: "files callback", Fn: func(item *nav.TraverseItem) error { GinkgoWriter.Printf("---> ๐ŸŒ™ FILES//%v-CALLBACK%v: '%v'\n", name, ex, item.Path) @@ -240,8 +240,8 @@ func filesCallback(name string, extended bool) nav.LabelledTraverseCallback { // === scope -func universalScopeCallback(name string) nav.LabelledTraverseCallback { - return nav.LabelledTraverseCallback{ +func universalScopeCallback(name string) *nav.LabelledTraverseCallback { + return &nav.LabelledTraverseCallback{ Label: "test universal callback", Fn: func(item *nav.TraverseItem) error { GinkgoWriter.Printf("---> ๐ŸŒ  UNIVERSAL//%v-CALLBACK-EX item-scope: (%v) '%v'\n", @@ -253,8 +253,8 @@ func universalScopeCallback(name string) nav.LabelledTraverseCallback { } } -func foldersScopeCallback(name string) nav.LabelledTraverseCallback { - return nav.LabelledTraverseCallback{ +func foldersScopeCallback(name string) *nav.LabelledTraverseCallback { + return &nav.LabelledTraverseCallback{ Label: "test folders callback", Fn: func(item *nav.TraverseItem) error { GinkgoWriter.Printf("---> ๐ŸŒŸ FOLDERS//%v-CALLBACK-EX item-scope: (%v) '%v'\n", @@ -267,8 +267,8 @@ func foldersScopeCallback(name string) nav.LabelledTraverseCallback { } } -func filesScopeCallback(name string) nav.LabelledTraverseCallback { - return nav.LabelledTraverseCallback{ +func filesScopeCallback(name string) *nav.LabelledTraverseCallback { + return &nav.LabelledTraverseCallback{ Label: "test files callback", Fn: func(item *nav.TraverseItem) error { GinkgoWriter.Printf("---> ๐ŸŒฌ๏ธ FILES//%v-CALLBACK-EX item-scope: (%v) '%v'\n", @@ -283,8 +283,8 @@ func filesScopeCallback(name string) nav.LabelledTraverseCallback { // === sort -func universalSortCallback(name string) nav.LabelledTraverseCallback { - return nav.LabelledTraverseCallback{ +func universalSortCallback(name string) *nav.LabelledTraverseCallback { + return &nav.LabelledTraverseCallback{ Label: "test universal callback", Fn: func(item *nav.TraverseItem) error { GinkgoWriter.Printf("---> ๐Ÿ’š UNIVERSAL//%v-SORT-CALLBACK-EX(scope:%v, depth:%v) '%v'\n", @@ -296,8 +296,8 @@ func universalSortCallback(name string) nav.LabelledTraverseCallback { } } -func foldersSortCallback(name string) nav.LabelledTraverseCallback { - return nav.LabelledTraverseCallback{ +func foldersSortCallback(name string) *nav.LabelledTraverseCallback { + return &nav.LabelledTraverseCallback{ Label: "test folders sort callback", Fn: func(item *nav.TraverseItem) error { GinkgoWriter.Printf("---> ๐Ÿ’œ FOLDERS//%v-SORT-CALLBACK-EX '%v'\n", @@ -310,8 +310,8 @@ func foldersSortCallback(name string) nav.LabelledTraverseCallback { } } -func filesSortCallback(name string) nav.LabelledTraverseCallback { - return nav.LabelledTraverseCallback{ +func filesSortCallback(name string) *nav.LabelledTraverseCallback { + return &nav.LabelledTraverseCallback{ Label: "test files sort callback", Fn: func(item *nav.TraverseItem) error { GinkgoWriter.Printf("---> ๐Ÿ’™ FILES//%v-SORT-CALLBACK-EX '%v'\n", @@ -324,8 +324,8 @@ func filesSortCallback(name string) nav.LabelledTraverseCallback { } } -func universalDepthCallback(name string, maxDepth int) nav.LabelledTraverseCallback { - return nav.LabelledTraverseCallback{ +func universalDepthCallback(name string, maxDepth int) *nav.LabelledTraverseCallback { + return &nav.LabelledTraverseCallback{ Label: "test universal depth callback", Fn: func(item *nav.TraverseItem) error { if item.Extension.Depth <= maxDepth { @@ -339,10 +339,10 @@ func universalDepthCallback(name string, maxDepth int) nav.LabelledTraverseCallb } } -func foldersCaseSensitiveCallback(first, second string) nav.LabelledTraverseCallback { +func foldersCaseSensitiveCallback(first, second string) *nav.LabelledTraverseCallback { recording := make(recordingMap) - return nav.LabelledTraverseCallback{ + return &nav.LabelledTraverseCallback{ Label: "test folders case sensitive callback", Fn: func(item *nav.TraverseItem) error { recording[item.Path] = len(item.Children) @@ -368,8 +368,8 @@ func foldersCaseSensitiveCallback(first, second string) nav.LabelledTraverseCall // === skip -func skipFolderCallback(skip, exclude string) nav.LabelledTraverseCallback { - return nav.LabelledTraverseCallback{ +func skipFolderCallback(skip, exclude string) *nav.LabelledTraverseCallback { + return &nav.LabelledTraverseCallback{ Label: "test skip folder callback", Fn: func(item *nav.TraverseItem) error { GinkgoWriter.Printf( @@ -385,8 +385,8 @@ func skipFolderCallback(skip, exclude string) nav.LabelledTraverseCallback { } } -func boostCallback(name string) nav.LabelledTraverseCallback { - return nav.LabelledTraverseCallback{ +func boostCallback(name string) *nav.LabelledTraverseCallback { + return &nav.LabelledTraverseCallback{ Label: "test boost callback", Fn: func(item *nav.TraverseItem) error { fmt.Printf("---> โฉ ON-boost-CALLBACK(%v) '%v'\n", name, item.Path) @@ -429,10 +429,10 @@ func readDirFakeErrorAt(name string) func(dirname string) ([]fs.DirEntry, error) } } -func errorCallback(name string, extended, hasError bool) nav.LabelledTraverseCallback { +func errorCallback(name string, extended, hasError bool) *nav.LabelledTraverseCallback { ex := lo.Ternary(extended, "-EX", "") - return nav.LabelledTraverseCallback{ + return &nav.LabelledTraverseCallback{ Label: "test error callback", Fn: func(item *nav.TraverseItem) error { GinkgoWriter.Printf("---> ๐Ÿ”ฅ %v-CALLBACK%v: '%v'\n", name, ex, item.Path) diff --git a/xfs/nav/marshal-state_test.go b/xfs/nav/marshal-state_test.go index 4d29c1f..c74fa9e 100644 --- a/xfs/nav/marshal-state_test.go +++ b/xfs/nav/marshal-state_test.go @@ -61,7 +61,7 @@ var _ = Describe("MarshalOptions", Ordered, func() { o.Store.Subscription = nav.SubscribeAny o.Store.DoExtend = true o.Store.FilterDefs = &filterDefs - o.Callback = nav.LabelledTraverseCallback{ + o.Callback = &nav.LabelledTraverseCallback{ Label: "test marshal state callback", Fn: func(_ *nav.TraverseItem) error { return nil @@ -98,7 +98,7 @@ var _ = Describe("MarshalOptions", Ordered, func() { o.Persist.Format = entry.format o.Store.DoExtend = true o.Store.FilterDefs = &filterDefs - o.Callback = nav.LabelledTraverseCallback{ + o.Callback = &nav.LabelledTraverseCallback{ Label: "test marshal state callback", Fn: func(item *nav.TraverseItem) error { return nil diff --git a/xfs/nav/navigation-async-defs.go b/xfs/nav/navigation-async-defs.go index fd813c8..e013df5 100644 --- a/xfs/nav/navigation-async-defs.go +++ b/xfs/nav/navigation-async-defs.go @@ -5,8 +5,9 @@ import ( ) type TraverseItemInput struct { - Item *TraverseItem - Fn TraverseCallback + Item *TraverseItem + Label string + Fn TraverseCallback } type TraverseItemJob = boost.Job[TraverseItemInput] type TraverseItemJobStream = boost.JobStream[TraverseItemInput] diff --git a/xfs/nav/navigation-frame.go b/xfs/nav/navigation-frame.go index bab9e7b..4daf20b 100644 --- a/xfs/nav/navigation-frame.go +++ b/xfs/nav/navigation-frame.go @@ -6,8 +6,8 @@ type navigationFrame struct { root utils.VarProp[string] currentPath utils.VarProp[string] listener *navigationListener - raw LabelledTraverseCallback // un-decorated (except for filter) client callback - client LabelledTraverseCallback // decorate-able client callback + raw *LabelledTraverseCallback // un-decorated (except for filter) client callback + client *LabelledTraverseCallback // decorate-able client callback filters *NavigationFilters notifiers notificationsSink periscope *navigationPeriscope @@ -43,7 +43,7 @@ func (f *navigationFrame) decorate(_ string, decorator *LabelledTraverseCallback // stack overflow due to infinite recursion. Its easy to search when decoration is // occurring in the code base, just search for decorate or go to references. // - f.client = *decorator + f.client = decorator } func (f *navigationFrame) save(active *ActiveState) { diff --git a/xfs/nav/navigation-listener.go b/xfs/nav/navigation-listener.go index b910099..8d1b325 100644 --- a/xfs/nav/navigation-listener.go +++ b/xfs/nav/navigation-listener.go @@ -31,7 +31,7 @@ const ( ListenRetired // conditional listening is now deactivated ) -type navigationListeningStates map[ListeningState]LabelledTraverseCallback +type navigationListeningStates map[ListeningState]*LabelledTraverseCallback type listenStatesParams struct { // currently used for makeStates and listener.decorate @@ -45,7 +45,7 @@ type listenStatesParams struct { type navigationListener struct { state ListeningState states navigationListeningStates - current LabelledTraverseCallback + current *LabelledTraverseCallback resumeStack *collections.Stack[*ListenTriggers] triggers *ListenTriggers } @@ -74,7 +74,7 @@ func (l *navigationListener) makeStates(params *listenStatesParams) { // ListenDeaf: params.frame.raw, - ListenFastward: LabelledTraverseCallback{ + ListenFastward: &LabelledTraverseCallback{ Label: "ListenFastward decorator", Fn: func(item *TraverseItem) error { // fast forwarding to resume point @@ -100,7 +100,7 @@ func (l *navigationListener) makeStates(params *listenStatesParams) { }, }, - ListenPending: LabelledTraverseCallback{ + ListenPending: &LabelledTraverseCallback{ Label: "ListenPending decorator", Fn: func(item *TraverseItem) error { // listening not yet started @@ -120,7 +120,7 @@ func (l *navigationListener) makeStates(params *listenStatesParams) { }, }, - ListenActive: LabelledTraverseCallback{ + ListenActive: &LabelledTraverseCallback{ Label: "ListenActive decorator", Fn: func(item *TraverseItem) error { // listening @@ -138,7 +138,7 @@ func (l *navigationListener) makeStates(params *listenStatesParams) { }, }, - ListenRetired: LabelledTraverseCallback{ + ListenRetired: &LabelledTraverseCallback{ Label: "ListenRetired decorator", Fn: func(_ *TraverseItem) error { return xi18n.NewTerminateTraverseError() diff --git a/xfs/nav/navigation-listener_test.go b/xfs/nav/navigation-listener_test.go index f486d6b..0868ed7 100644 --- a/xfs/nav/navigation-listener_test.go +++ b/xfs/nav/navigation-listener_test.go @@ -45,7 +45,7 @@ var _ = Describe("Listener", Ordered, func() { } } o.Store.DoExtend = entry.extended - o.Callback = nav.LabelledTraverseCallback{ + o.Callback = &nav.LabelledTraverseCallback{ Label: "test listener callback", Fn: func(item *nav.TraverseItem) error { GinkgoWriter.Printf("---> ๐Ÿ”Š LISTENING-CALLBACK: name: '%v'\n", @@ -311,7 +311,7 @@ var _ = Describe("Listener", Ordered, func() { GinkgoWriter.Printf("===> โ›” Stop Listening: '%v'\n", description) } o.Store.DoExtend = true - o.Callback = nav.LabelledTraverseCallback{ + o.Callback = &nav.LabelledTraverseCallback{ Label: "Listener Test Callback", Fn: func(item *nav.TraverseItem) error { GinkgoWriter.Printf("---> ๐Ÿ”Š LISTENING-CALLBACK: name: '%v'\n", diff --git a/xfs/nav/navigation-with-runner_test.go b/xfs/nav/navigation-with-runner_test.go index beeb843..72b4494 100644 --- a/xfs/nav/navigation-with-runner_test.go +++ b/xfs/nav/navigation-with-runner_test.go @@ -37,7 +37,7 @@ var _ = Describe("NavigationWithRunner", Ordered, func() { Context("resume and worker pool acceleration", func() { When("universal: listen pending(logged)", func() { - It("should: ...", SpecTimeout(time.Second*5), func(ctxSpec SpecContext) { + It("๐Ÿงช should: ...", SpecTimeout(time.Second*5), func(ctxSpec SpecContext) { ctx, cancel := context.WithCancel(ctxSpec) path := helpers.Path(root, "RETRO-WAVE") restorer := func(o *nav.TraverseOptions, active *nav.ActiveState) { @@ -60,7 +60,6 @@ var _ = Describe("NavigationWithRunner", Ordered, func() { createWith := nav.RunnerWithResume | nav.RunnerWithPool now := 3 JobsChOut := make(boost.JobStream[nav.TraverseItemInput], DefaultJobsChSize) - outputChTimeout := time.Second jobsOutputChOut := make(boost.JobOutputStream[nav.TraverseOutput], DefaultJobsChSize) result, err := nav.New().With(createWith, &nav.RunnerInfo{ @@ -102,4 +101,52 @@ var _ = Describe("NavigationWithRunner", Ordered, func() { }) }) }) + + When("Filter Applied", func() { + It("๐Ÿงช should: only invoke sync callback for filtered items", func(ctxSpec SpecContext) { + ctx, cancel := context.WithCancel(ctxSpec) + defer cancel() + + path := helpers.Path(root, "RETRO-WAVE") + + wgan := boost.NewAnnotatedWaitGroup("๐Ÿ‚ traversal") + wgan.Add(1, navigatorRoutineName) + now := 3 + jobsChOut := make(boost.JobStream[nav.TraverseItemInput], DefaultJobsChSize) + + filterDefs := &nav.FilterDefinitions{ + Node: nav.FilterDef{ + Type: nav.FilterTypeGlobEn, + Description: "flac files", + Pattern: "*.flac", + Scope: nav.ScopeLeafEn, + }, + } + + result, err := nav.New().Primary(&nav.Prime{ + Path: path, + OptionsFn: func(o *nav.TraverseOptions) { + o.Notify.OnBegin = begin("๐Ÿ›ก๏ธ") + o.Store.Subscription = nav.SubscribeFiles + o.Callback = universalCallbackNoAssert( + "filtered *.flac files: WithPool", + NotExtended, + ) + o.Store.FilterDefs = filterDefs + }, + }).WithPool( + &nav.AsyncInfo{ + NavigatorRoutineName: navigatorRoutineName, + WaitAQ: wgan, + JobsChanOut: jobsChOut, + }, + ).NoW(now).Run(ctx, cancel) + + wgan.Wait("๐Ÿ‘พ test-main") + + Expect(err).Error().To(BeNil()) + _ = result.Session.StartedAt() + _ = result.Session.Elapsed() + }) + }) }) diff --git a/xfs/nav/navigator-abstract.go b/xfs/nav/navigator-abstract.go index 0559c75..fdd91bf 100644 --- a/xfs/nav/navigator-abstract.go +++ b/xfs/nav/navigator-abstract.go @@ -23,12 +23,10 @@ func (n *navigator) options() *TraverseOptions { func (n *navigator) ensync( ctx context.Context, - cancel context.CancelFunc, + _ context.CancelFunc, // we don't need this here; only the worker pool needs it! frame *navigationFrame, ai *AsyncInfo, ) { - _ = cancel - decorated := frame.client decorator := &LabelledTraverseCallback{ Label: "boost decorator", @@ -37,8 +35,8 @@ func (n *navigator) ensync( if pe := recover(); pe != nil { if err, ok := pe.(error); ok || strings.Contains(err.Error(), "send on closed channel") { - fmt.Printf("---> โ˜ ๏ธโ˜ ๏ธโ˜ ๏ธ ENSYNC-NAV-CALLBACK(panic on close): '%v' (err:'%v')\n", - item.Path, pe, + n.logger().Error("โ˜ ๏ธโ˜ ๏ธโ˜ ๏ธ send on closed channel", + log.String("item-path", item.Path), ) } else { // Let panic propagate to whoever can handle it @@ -47,7 +45,6 @@ func (n *navigator) ensync( } } }() - fmt.Printf("---> ๐Ÿฌ ENSYNC-NAV-CALLBACK: '%v' \n", item.Path) var err error select { @@ -57,8 +54,9 @@ func (n *navigator) ensync( job := TraverseItemJob{ ID: fmt.Sprintf("JOB-ID:%v", uuid.NewString()), Input: TraverseItemInput{ - Item: item, - Fn: decorated.Fn, + Item: item, + Fn: decorated.Fn, + Label: decorated.Label, }, SequenceNo: -999, } @@ -71,8 +69,6 @@ func (n *navigator) ensync( // // intermittent panic: send on closed channel, in fastward resume scenarios // 'gr:observable-navigator' - - fmt.Printf("-->> ๐Ÿ‡๐Ÿ‡ sending job(%v)\n", job.ID) } } diff --git a/xfs/nav/resume-strategy_test.go b/xfs/nav/resume-strategy_test.go index 2e888f5..b998b90 100644 --- a/xfs/nav/resume-strategy_test.go +++ b/xfs/nav/resume-strategy_test.go @@ -246,7 +246,7 @@ var _ = Describe("Resume", Ordered, func() { }, } - o.Callback = nav.LabelledTraverseCallback{ + o.Callback = &nav.LabelledTraverseCallback{ Label: "unit test callback for resume", Fn: func(item *nav.TraverseItem) error { depth := lo.TernaryF(o.Store.DoExtend, diff --git a/xfs/nav/traverse-navigator-error_test.go b/xfs/nav/traverse-navigator-error_test.go index 60c875f..bd7f20e 100644 --- a/xfs/nav/traverse-navigator-error_test.go +++ b/xfs/nav/traverse-navigator-error_test.go @@ -70,7 +70,7 @@ var _ = Describe("TraverseNavigator errors", Ordered, func() { nav.DefaultExtendHookFn(navi, entries) } o.Store.DoExtend = true - o.Callback = nav.LabelledTraverseCallback{ + o.Callback = &nav.LabelledTraverseCallback{ Label: "test callback", Fn: func(_ *nav.TraverseItem) error { return nil @@ -100,7 +100,7 @@ var _ = Describe("TraverseNavigator errors", Ordered, func() { o.Store.Subscription = nav.SubscribeFolders o.Hooks.ReadDirectory = readDirFakeError o.Store.DoExtend = true - o.Callback = nav.LabelledTraverseCallback{ + o.Callback = &nav.LabelledTraverseCallback{ Label: "test callback", Fn: func(item *nav.TraverseItem) error { GinkgoWriter.Printf("---> ๐Ÿ”ฅ READ-ERR-CALLBACK: '%v', error: '%v'\n", @@ -242,7 +242,7 @@ var _ = Describe("TraverseNavigator errors", Ordered, func() { Node: filterDef, } o.Notify.OnBegin = begin("๐Ÿงฒ") - o.Callback = nav.LabelledTraverseCallback{ + o.Callback = &nav.LabelledTraverseCallback{ Label: "test callback", Fn: func(item *nav.TraverseItem) error { GinkgoWriter.Printf("===> path:'%s'\n", item.Path) @@ -269,7 +269,7 @@ var _ = Describe("TraverseNavigator errors", Ordered, func() { const path = "/foo" optionFn := func(o *nav.TraverseOptions) { o.Store.Subscription = nav.SubscribeAny - o.Callback = nav.LabelledTraverseCallback{ + o.Callback = &nav.LabelledTraverseCallback{ Label: "test callback", Fn: func(item *nav.TraverseItem) error { GinkgoWriter.Printf("===> path:'%s'\n", item.Path) @@ -297,7 +297,7 @@ var _ = Describe("TraverseNavigator errors", Ordered, func() { const path = "/foo" optionFn := func(o *nav.TraverseOptions) { o.Store.Subscription = nav.SubscribeAny - o.Callback = nav.LabelledTraverseCallback{ + o.Callback = &nav.LabelledTraverseCallback{ Label: "test callback", Fn: func(item *nav.TraverseItem) error { GinkgoWriter.Printf("===> path:'%s'\n", item.Path) @@ -328,7 +328,7 @@ var _ = Describe("TraverseNavigator errors", Ordered, func() { optionFn := func(o *nav.TraverseOptions) { o.Store.DoExtend = true o.Store.Subscription = nav.SubscribeAny - o.Callback = nav.LabelledTraverseCallback{ + o.Callback = &nav.LabelledTraverseCallback{ Label: "test callback", Fn: func(item *nav.TraverseItem) error { GinkgoWriter.Printf("===> path:'%s'\n", item.Path) diff --git a/xfs/nav/traverse-navigator-scope_test.go b/xfs/nav/traverse-navigator-scope_test.go index a26c59f..03b4e5a 100644 --- a/xfs/nav/traverse-navigator-scope_test.go +++ b/xfs/nav/traverse-navigator-scope_test.go @@ -29,7 +29,7 @@ var _ = Describe("TraverseNavigatorScope", Ordered, func() { func(entry *scopeTE) { recording := make(recordingScopeMap) - scopeRecorder := nav.LabelledTraverseCallback{ + scopeRecorder := &nav.LabelledTraverseCallback{ Label: "test callback", Fn: func(item *nav.TraverseItem) error { _, found := recording[item.Extension.Name] diff --git a/xfs/nav/traverse-navigator-sort_test.go b/xfs/nav/traverse-navigator-sort_test.go index 71187d9..3d08e4c 100644 --- a/xfs/nav/traverse-navigator-sort_test.go +++ b/xfs/nav/traverse-navigator-sort_test.go @@ -31,7 +31,7 @@ var _ = Describe("TraverseNavigatorSort", Ordered, func() { recording := make(recordingOrderMap) counter := 0 - recorder := nav.LabelledTraverseCallback{ + recorder := &nav.LabelledTraverseCallback{ Label: "test recorder callback", Fn: func(item *nav.TraverseItem) error { _, found := recording[item.Extension.Name] diff --git a/xfs/nav/traverse-navigator-subpath_test.go b/xfs/nav/traverse-navigator-subpath_test.go index 84aeddf..d713cbe 100644 --- a/xfs/nav/traverse-navigator-subpath_test.go +++ b/xfs/nav/traverse-navigator-subpath_test.go @@ -38,7 +38,7 @@ var _ = Describe("TraverseNavigatorSubpath", Ordered, func() { o.Store.Subscription = nav.SubscribeAny o.Store.Behaviours.SubPath.KeepTrailingSep = true o.Store.DoExtend = true - o.Callback = nav.LabelledTraverseCallback{ + o.Callback = &nav.LabelledTraverseCallback{ Label: "test sub-path callback", Fn: func(item *nav.TraverseItem) error { if expected, ok := expectations[item.Extension.Name]; ok { @@ -80,7 +80,7 @@ var _ = Describe("TraverseNavigatorSubpath", Ordered, func() { o.Hooks.FileSubPath = nav.RootItemSubPath o.Store.Behaviours.SubPath.KeepTrailingSep = true o.Store.DoExtend = true - o.Callback = nav.LabelledTraverseCallback{ + o.Callback = &nav.LabelledTraverseCallback{ Label: "test sub-path callback", Fn: func(item *nav.TraverseItem) error { if expected, ok := expectations[item.Extension.Name]; ok { @@ -120,7 +120,7 @@ var _ = Describe("TraverseNavigatorSubpath", Ordered, func() { o.Store.Behaviours.SubPath.KeepTrailingSep = false o.Store.Subscription = nav.SubscribeAny o.Store.DoExtend = true - o.Callback = nav.LabelledTraverseCallback{ + o.Callback = &nav.LabelledTraverseCallback{ Label: "test sub-path callback", Fn: func(item *nav.TraverseItem) error { if expected, ok := expectations[item.Extension.Name]; ok { diff --git a/xfs/nav/traverse-navigator_test.go b/xfs/nav/traverse-navigator_test.go index cb80b5e..dfb3d3a 100644 --- a/xfs/nav/traverse-navigator_test.go +++ b/xfs/nav/traverse-navigator_test.go @@ -35,7 +35,7 @@ var _ = Describe("TraverseNavigator(logged)", Ordered, func() { recording := make(recordingMap) visited := []string{} - once := nav.LabelledTraverseCallback{ + once := &nav.LabelledTraverseCallback{ Label: "test once decorator", Fn: func(item *nav.TraverseItem) error { _, found := recording[item.Path] @@ -46,7 +46,7 @@ var _ = Describe("TraverseNavigator(logged)", Ordered, func() { }, } - visitor := nav.LabelledTraverseCallback{ + visitor := &nav.LabelledTraverseCallback{ Fn: func(item *nav.TraverseItem) error { return once.Fn(item) }, @@ -295,7 +295,7 @@ var _ = Describe("TraverseNavigator(logged)", Ordered, func() { recording := make(recordingMap) visited := []string{} - once := nav.LabelledTraverseCallback{ + once := &nav.LabelledTraverseCallback{ Label: "test once callback", Fn: func(item *nav.TraverseItem) error { _, found := recording[item.Extension.Name] diff --git a/xfs/nav/traverse-options.go b/xfs/nav/traverse-options.go index efd4ec6..8532f31 100644 --- a/xfs/nav/traverse-options.go +++ b/xfs/nav/traverse-options.go @@ -181,7 +181,7 @@ type TraverseOptions struct { // Callback function to invoke for every item visited in the file system. // - Callback LabelledTraverseCallback `json:"-"` + Callback *LabelledTraverseCallback `json:"-"` // Notify collection of notification function. //