internal/component: Further optimize initialization
This commit is contained in:
parent
abc985892a
commit
84dcaa62a9
6 changed files with 280 additions and 294 deletions
|
|
@ -28,8 +28,8 @@ type Distillery struct {
|
|||
// But for now this will just hold upstream configuration.
|
||||
Upstream Upstream
|
||||
|
||||
// components hold references to the various components of the distillery.
|
||||
components
|
||||
// Pool holds all the components in this pool
|
||||
pool component.Pool
|
||||
}
|
||||
|
||||
// Upstream contains the configuration for accessing remote configuration.
|
||||
|
|
@ -47,6 +47,21 @@ func (dis *Distillery) Context() context.Context {
|
|||
// PUBLIC COMPONENT GETTERS
|
||||
//
|
||||
|
||||
// e is a convenience function to export a single component
|
||||
func e[C component.Component](dis *Distillery) C {
|
||||
return component.ExportComponent[C](
|
||||
&dis.pool,
|
||||
dis.register,
|
||||
)
|
||||
}
|
||||
|
||||
func ea[C component.Component](dis *Distillery) []C {
|
||||
return component.ExportComponents[C](
|
||||
&dis.pool,
|
||||
dis.register,
|
||||
)
|
||||
}
|
||||
|
||||
func (dis *Distillery) Control() *control.Control {
|
||||
return e[*control.Control](dis)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue