curre/builder.go
2022-09-10 13:08:16 +02:00

24 lines
670 B
Go

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(
init func(ctx context.Context) error,
start func(ctx context.Context) error,
stop func(ctx context.Context) error,
) Component {
return &FunctionalComponent{
init, start, stop,
}
}
func (fc *FunctionalComponent) Init(ctx context.Context) error { return fc.init(ctx) }
func (fc *FunctionalComponent) Start(ctx context.Context) error { return fc.start(ctx) }
func (fc *FunctionalComponent) Stop(ctx context.Context) error { return fc.stop(ctx) }