internal/component: Further optimize initialization

This commit is contained in:
Tom Wiesing 2022-10-05 15:23:29 +02:00
parent abc985892a
commit 84dcaa62a9
No known key found for this signature in database
6 changed files with 280 additions and 294 deletions

View file

@ -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)
}