curre/builder.go

35 lines
648 B
Go
Raw Normal View History

2022-09-10 13:08:16 +02:00
package curre
import "context"
type FunctionalComponent struct {
init func(ctx context.Context) error
start func(ctx context.Context) error
stop func(ctx context.Context) error
}
func NewFunctionalComponent(
2022-09-10 19:53:19 +02:00
fc *FunctionalComponent,
2022-09-10 13:08:16 +02:00
) Component {
2022-09-10 19:53:19 +02:00
return fc
2022-09-10 13:08:16 +02:00
}
2022-09-10 19:53:19 +02:00
func (fc *FunctionalComponent) Init(ctx context.Context) error {
if fc.init != nil {
return fc.init(ctx)
}
return nil
}
func (fc *FunctionalComponent) Start(ctx context.Context) error {
if fc.start != nil {
return fc.start(ctx)
}
return nil
}
func (fc *FunctionalComponent) Stop(ctx context.Context) error {
if fc.stop != nil {
return fc.stop(ctx)
}
return nil
}