This commit is contained in:
2022-09-10 13:08:16 +02:00
parent 33ac911f9c
commit 78c0c309d7
5 changed files with 28 additions and 5 deletions

23
builder.go Normal file
View File

@@ -0,0 +1,23 @@
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) }