Skip to content

Commit

Permalink
ref(proxy): consolidate controller (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
plastikfan committed Dec 26, 2023
1 parent 6d22f0c commit b571714
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 84 deletions.
20 changes: 0 additions & 20 deletions src/app/proxy/controller-full.go

This file was deleted.

20 changes: 3 additions & 17 deletions src/app/proxy/controller-registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
},
},
}
Expand Down
36 changes: 0 additions & 36 deletions src/app/proxy/controller-sampler.go

This file was deleted.

27 changes: 27 additions & 0 deletions src/app/proxy/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion src/app/proxy/enter-shrink.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion src/app/proxy/entry-base.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 0 additions & 9 deletions src/app/proxy/proxy-defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b571714

Please sign in to comment.