with fc
This commit is contained in:
23
builder.go
Normal file
23
builder.go
Normal 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) }
|
Reference in New Issue
Block a user