internal/component: Move Pool into lazy package
This commit is contained in:
parent
bcfd0765b0
commit
7c3c84e116
8 changed files with 261 additions and 139 deletions
|
|
@ -18,7 +18,7 @@ import (
|
|||
)
|
||||
|
||||
// register returns all components of the distillery
|
||||
func (dis *Distillery) register(context *component.PoolContext) []component.Component {
|
||||
func (dis *Distillery) register(context component.ComponentPoolContext) []component.Component {
|
||||
return []component.Component{
|
||||
ra[*web.Web](dis, context),
|
||||
|
||||
|
|
@ -58,11 +58,11 @@ func (dis *Distillery) register(context *component.PoolContext) []component.Comp
|
|||
}
|
||||
|
||||
// r initializes a component from the provided distillery.
|
||||
func r[C component.Component](dis *Distillery, context *component.PoolContext, init func(component C)) C {
|
||||
return component.Make(context, dis.Core, init)
|
||||
func r[C component.Component](dis *Distillery, context component.ComponentPoolContext, init func(component C)) C {
|
||||
return component.MakeComponent(context, dis.Core, init)
|
||||
}
|
||||
|
||||
// ra is like r, but does not provided additional initialization
|
||||
func ra[C component.Component](dis *Distillery, context *component.PoolContext) C {
|
||||
func ra[C component.Component](dis *Distillery, context component.ComponentPoolContext) C {
|
||||
return r[C](dis, context, nil)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ type Distillery struct {
|
|||
Upstream Upstream
|
||||
|
||||
// Pool holds all the components in this pool
|
||||
pool component.Pool
|
||||
pool component.ComponentPool
|
||||
}
|
||||
|
||||
// Upstream contains the configuration for accessing remote configuration.
|
||||
|
|
@ -54,6 +54,7 @@ func (dis *Distillery) Context() context.Context {
|
|||
func e[C component.Component](dis *Distillery) C {
|
||||
return component.ExportComponent[C](
|
||||
&dis.pool,
|
||||
dis.Core,
|
||||
dis.register,
|
||||
)
|
||||
}
|
||||
|
|
@ -61,6 +62,7 @@ func e[C component.Component](dis *Distillery) C {
|
|||
func ea[C component.Component](dis *Distillery) []C {
|
||||
return component.ExportComponents[C](
|
||||
&dis.pool,
|
||||
dis.Core,
|
||||
dis.register,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue