24 lines
670 B
Go
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) }
|