From 4f9c71d612e807f33d23be2aa07422f4e9a43e19 Mon Sep 17 00:00:00 2001 From: plastikfan Date: Tue, 26 Dec 2023 16:59:56 +0000 Subject: [PATCH] ref(proxy): consolidate controller (#87) --- src/app/proxy/controller-full.go | 20 ---------------- src/app/proxy/controller-registry.go | 20 +++------------- src/app/proxy/controller-sampler.go | 36 ---------------------------- src/app/proxy/controller.go | 27 +++++++++++++++++++++ src/app/proxy/enter-shrink.go | 1 - src/app/proxy/entry-base.go | 1 - src/app/proxy/proxy-defs.go | 9 ------- 7 files changed, 30 insertions(+), 84 deletions(-) delete mode 100644 src/app/proxy/controller-full.go delete mode 100644 src/app/proxy/controller-sampler.go diff --git a/src/app/proxy/controller-full.go b/src/app/proxy/controller-full.go deleted file mode 100644 index 152ad23..0000000 --- a/src/app/proxy/controller-full.go +++ /dev/null @@ -1,20 +0,0 @@ -package proxy - -import ( - "github.com/snivilised/cobrass" - "github.com/snivilised/extendio/xfs/nav" -) - -type FullController struct { - controller -} - -func (c *FullController) OnNewShrinkItem( - item *nav.TraverseItem, - thirdPartyCL cobrass.ThirdPartyCommandLine, -) error { - _ = item - _ = thirdPartyCL - - return nil -} diff --git a/src/app/proxy/controller-registry.go b/src/app/proxy/controller-registry.go index 451b09b..9b86493 100644 --- a/src/app/proxy/controller-registry.go +++ b/src/app/proxy/controller-registry.go @@ -10,24 +10,10 @@ func NewControllerRegistry(shared *SharedControllerInfo) *ControllerRegistry { // see: https://www.sobyte.net/post/2022-03/think-in-sync-pool/ // New: func() interface{} { - switch shared.Type { - case ControllerTypeFullEn: - return &FullController{ - controller: controller{ - shared: shared, - }, - } - - case ControllerTypeSamplerEn: - return &SamplerController{ - controller: controller{ - shared: shared, - private: &privateControllerInfo{}, - }, - } + return &controller{ + shared: shared, + private: &privateControllerInfo{}, } - - panic("undefined controller type") }, }, } diff --git a/src/app/proxy/controller-sampler.go b/src/app/proxy/controller-sampler.go deleted file mode 100644 index 17c919c..0000000 --- a/src/app/proxy/controller-sampler.go +++ /dev/null @@ -1,36 +0,0 @@ -package proxy - -import ( - "github.com/snivilised/extendio/xfs/nav" -) - -type SamplerController struct { - controller -} - -func (c *SamplerController) OnNewShrinkItem(item *nav.TraverseItem) error { - // create a master path info here and pass into the sequences - // to replace the individual properties on the step - // - pi := &pathInfo{ - item: item, - scheme: c.shared.Inputs.Root.ProfileFam.Native.Scheme, - profile: c.shared.Inputs.Root.ProfileFam.Native.Profile, - origin: item.Extension.Parent, - } - - var sequence Sequence - - switch { - case pi.profile != "": - sequence = c.profileSequence(pi) - - case pi.scheme != "": - sequence = c.schemeSequence(pi) - - default: - sequence = c.adhocSequence(pi) - } - - return c.Run(item, sequence) -} diff --git a/src/app/proxy/controller.go b/src/app/proxy/controller.go index 3ba1abf..e7cdd3b 100644 --- a/src/app/proxy/controller.go +++ b/src/app/proxy/controller.go @@ -18,6 +18,33 @@ type controller struct { private *privateControllerInfo } +func (c *controller) OnNewShrinkItem(item *nav.TraverseItem) error { + // create a master path info here and pass into the sequences + // to replace the individual properties on the step + // + pi := &pathInfo{ + item: item, + scheme: c.shared.Inputs.Root.ProfileFam.Native.Scheme, + profile: c.shared.Inputs.Root.ProfileFam.Native.Profile, + origin: item.Extension.Parent, + } + + var sequence Sequence + + switch { + case pi.profile != "": + sequence = c.profileSequence(pi) + + case pi.scheme != "": + sequence = c.schemeSequence(pi) + + default: + sequence = c.adhocSequence(pi) + } + + return c.Run(item, sequence) +} + func (c *controller) profileSequence( pi *pathInfo, ) Sequence { diff --git a/src/app/proxy/enter-shrink.go b/src/app/proxy/enter-shrink.go index 04cd89f..724dccc 100644 --- a/src/app/proxy/enter-shrink.go +++ b/src/app/proxy/enter-shrink.go @@ -130,7 +130,6 @@ func (e *ShrinkEntry) ConfigureOptions(o *nav.TraverseOptions) { } e.Registry = NewControllerRegistry(&SharedControllerInfo{ - Type: ControllerTypeSamplerEn, // TODO: to come from an arg !!! Options: e.Options, program: e.Program, profiles: e.ProfilesCFG, diff --git a/src/app/proxy/entry-base.go b/src/app/proxy/entry-base.go index dfdbaa3..05b5e3c 100644 --- a/src/app/proxy/entry-base.go +++ b/src/app/proxy/entry-base.go @@ -138,7 +138,6 @@ func (e *EntryBase) ConfigureOptions(o *nav.TraverseOptions) { // if e.Registry == nil { e.Registry = NewControllerRegistry(&SharedControllerInfo{ - Type: ControllerTypeSamplerEn, // TODO: to come from an arg !!! Options: e.Options, program: e.Program, profiles: e.ProfilesCFG, diff --git a/src/app/proxy/proxy-defs.go b/src/app/proxy/proxy-defs.go index d645c7e..54317c3 100644 --- a/src/app/proxy/proxy-defs.go +++ b/src/app/proxy/proxy-defs.go @@ -4,16 +4,7 @@ import ( "github.com/snivilised/extendio/xfs/nav" ) -type ControllerTypeEnum uint - -const ( - _ ControllerTypeEnum = iota - ControllerTypeFullEn - ControllerTypeSamplerEn -) - type SharedControllerInfo struct { - Type ControllerTypeEnum Options *nav.TraverseOptions program Executor profiles ProfilesConfig