generated from snivilised/arcadia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref(proxy): rename runner to controller (#74)
- Loading branch information
1 parent
0836fea
commit a195177
Showing
12 changed files
with
137 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package proxy | ||
|
||
import ( | ||
"sync" | ||
) | ||
|
||
func NewControllerRegistry(shared *SharedControllerInfo) *ControllerRegistry { | ||
return &ControllerRegistry{ | ||
pool: sync.Pool{ | ||
// 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, | ||
}, | ||
} | ||
} | ||
|
||
panic("undefined controller type") | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
type ControllerRegistry struct { | ||
pool sync.Pool | ||
} | ||
|
||
func (cr *ControllerRegistry) Get() ItemController { | ||
return cr.pool.Get().(ItemController) | ||
} | ||
|
||
func (cr *ControllerRegistry) Put(controller ItemController) { | ||
controller.Reset() | ||
cr.pool.Put(controller) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package proxy | ||
|
||
import ( | ||
"github.com/snivilised/extendio/xfs/nav" | ||
) | ||
|
||
type SamplerController struct { | ||
controller | ||
} | ||
|
||
func (c *SamplerController) OnNewShrinkItem(item *nav.TraverseItem, | ||
positional []string, | ||
) error { | ||
_ = positional | ||
|
||
profileName := c.shared.Inputs.Root.ProfileFam.Native.Profile | ||
schemeName := c.shared.Inputs.Root.ProfileFam.Native.Scheme | ||
|
||
var sequence Sequence | ||
|
||
switch { | ||
case profileName != "": | ||
sequence = c.profileSequence(profileName, item.Path) | ||
|
||
case schemeName != "": | ||
sequence = c.schemeSequence(schemeName, item.Path) | ||
|
||
default: | ||
sequence = c.adhocSequence(item.Path) | ||
} | ||
|
||
return c.Run(item, sequence) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.