@@ -107,14 +107,14 @@ type namedModuleFunc struct {
107107 name string
108108}
109109
110- // NamedComponentFunc is wrapper for ReadyDoneFactory with additional fields:
110+ // NamedComponentFactory is wrapper for ReadyDoneFactory with additional fields:
111111// Name - name of the component
112112// ErrorHandler - error handler for the component
113113// Dependencies - list of dependencies for the component that should be ready before
114114// the component is started
115- type NamedComponentFunc [Input any ] struct {
116- FN ReadyDoneFactory [Input ]
117- Name string
115+ type NamedComponentFactory [Input any ] struct {
116+ ComponentFactory ReadyDoneFactory [Input ]
117+ Name string
118118
119119 ErrorHandler component.OnError
120120 Dependencies * DependencyList
@@ -133,7 +133,7 @@ type FlowNodeBuilder struct {
133133 * NodeConfig
134134 flags * pflag.FlagSet
135135 modules []namedModuleFunc
136- components []NamedComponentFunc [* NodeConfig ]
136+ components []NamedComponentFactory [* NodeConfig ]
137137 postShutdownFns []func () error
138138 preInitFns []BuilderFunc
139139 postInitFns []BuilderFunc
@@ -1566,7 +1566,7 @@ func AddWorkersFromComponents[Input any](
15661566 log zerolog.Logger ,
15671567 input Input ,
15681568 componentBuilder component.ComponentManagerBuilder ,
1569- components []NamedComponentFunc [Input ],
1569+ components []NamedComponentFactory [Input ],
15701570) {
15711571 // The parent/started channels are used to enforce serial startup.
15721572 // - parent is the started channel of the previous component.
@@ -1578,7 +1578,7 @@ func AddWorkersFromComponents[Input any](
15781578 parent := make (chan struct {})
15791579 close (parent )
15801580
1581- asyncComponents := []NamedComponentFunc [Input ]{}
1581+ asyncComponents := []NamedComponentFactory [Input ]{}
15821582
15831583 // Run all components
15841584 for _ , f := range components {
@@ -1620,7 +1620,7 @@ func AddWorkersFromComponents[Input any](
16201620// using their ReadyDoneAware interface. After components are updated to use the idempotent
16211621// ReadyDoneAware interface and explicitly wait for their dependencies to be ready, we can remove
16221622// this channel chaining.
1623- func WorkerFromComponent [Input any ](log zerolog.Logger , input Input , v NamedComponentFunc [Input ], dependencies <- chan struct {}, started func ()) component.ComponentWorker {
1623+ func WorkerFromComponent [Input any ](log zerolog.Logger , input Input , v NamedComponentFactory [Input ], dependencies <- chan struct {}, started func ()) component.ComponentWorker {
16241624 // Add a closure that starts the component when the node is started, and then waits for it to exit
16251625 // gracefully.
16261626 // Startup for all components will happen in parallel, and components can use their dependencies'
@@ -1635,7 +1635,7 @@ func WorkerFromComponent[Input any](log zerolog.Logger, input Input, v NamedComp
16351635
16361636 logger .Info ().Msg ("component initialization started" )
16371637 // First, build the component using the factory method.
1638- readyAware , err := v .FN (input )
1638+ readyAware , err := v .ComponentFactory (input )
16391639 if err != nil {
16401640 ctx .Throw (fmt .Errorf ("component %s initialization failed: %w" , v .Name , err ))
16411641 }
@@ -1689,7 +1689,7 @@ func WorkerFromComponent[Input any](log zerolog.Logger, input Input, v NamedComp
16891689func WorkerFromRestartableComponent [Input any ](
16901690 log zerolog.Logger ,
16911691 input Input ,
1692- v NamedComponentFunc [Input ],
1692+ v NamedComponentFactory [Input ],
16931693 parentReady <- chan struct {},
16941694 started func (),
16951695) component.ComponentWorker {
@@ -1713,7 +1713,7 @@ func WorkerFromRestartableComponent[Input any](
17131713 // This may be called multiple times if the component is restarted
17141714 componentFactory := func () (component.Component , error ) {
17151715 log .Info ().Msg ("component initialization started" )
1716- c , err := v .FN (input )
1716+ c , err := v .ComponentFactory (input )
17171717 if err != nil {
17181718 return nil , err
17191719 }
@@ -1774,9 +1774,9 @@ func (fnb *FlowNodeBuilder) AdminCommand(command string, f func(config *NodeConf
17741774// In both cases, the object is started when the node is run, and the node will wait for the
17751775// component to exit gracefully.
17761776func (fnb * FlowNodeBuilder ) Component (name string , f ReadyDoneFactory [* NodeConfig ]) NodeBuilder {
1777- fnb .components = append (fnb .components , NamedComponentFunc [* NodeConfig ]{
1778- FN : f ,
1779- Name : name ,
1777+ fnb .components = append (fnb .components , NamedComponentFactory [* NodeConfig ]{
1778+ ComponentFactory : f ,
1779+ Name : name ,
17801780 })
17811781 return fnb
17821782}
@@ -1795,10 +1795,10 @@ func (fnb *FlowNodeBuilder) Component(name string, f ReadyDoneFactory[*NodeConfi
17951795func (fnb * FlowNodeBuilder ) DependableComponent (name string , f ReadyDoneFactory [* NodeConfig ], dependencies * DependencyList ) NodeBuilder {
17961796 // Note: dependencies are passed as a struct to allow updating the list after calling this method.
17971797 // Passing a slice instead would result in out of sync metadata since slices are passed by reference
1798- fnb .components = append (fnb .components , NamedComponentFunc [* NodeConfig ]{
1799- FN : f ,
1800- Name : name ,
1801- Dependencies : dependencies ,
1798+ fnb .components = append (fnb .components , NamedComponentFactory [* NodeConfig ]{
1799+ ComponentFactory : f ,
1800+ Name : name ,
1801+ Dependencies : dependencies ,
18021802 })
18031803 return fnb
18041804}
@@ -1809,9 +1809,9 @@ func (fnb *FlowNodeBuilder) OverrideComponent(name string, f ReadyDoneFactory[*N
18091809 for i := 0 ; i < len (fnb .components ); i ++ {
18101810 if fnb .components [i ].Name == name {
18111811 // found component with the name, override it.
1812- fnb .components [i ] = NamedComponentFunc [* NodeConfig ]{
1813- FN : f ,
1814- Name : name ,
1812+ fnb .components [i ] = NamedComponentFactory [* NodeConfig ]{
1813+ ComponentFactory : f ,
1814+ Name : name ,
18151815 }
18161816
18171817 return fnb
@@ -1836,10 +1836,10 @@ func (fnb *FlowNodeBuilder) OverrideComponent(name string, f ReadyDoneFactory[*N
18361836//
18371837// Any irrecoverable errors thrown by the component will be passed to the provided error handler.
18381838func (fnb * FlowNodeBuilder ) RestartableComponent (name string , f ReadyDoneFactory [* NodeConfig ], errorHandler component.OnError ) NodeBuilder {
1839- fnb .components = append (fnb .components , NamedComponentFunc [* NodeConfig ]{
1840- FN : f ,
1841- Name : name ,
1842- ErrorHandler : errorHandler ,
1839+ fnb .components = append (fnb .components , NamedComponentFactory [* NodeConfig ]{
1840+ ComponentFactory : f ,
1841+ Name : name ,
1842+ ErrorHandler : errorHandler ,
18431843 })
18441844 return fnb
18451845}
0 commit comments