Files
opencloud/opencloud/pkg/runtime/service/sutureservice.go
Jörn Friedrich Dreyer 5aa5ab843a ociscfg -> occfg
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2025-01-14 12:44:00 +01:00

30 lines
744 B
Go

package service
import (
"context"
occfg "github.com/opencloud-eu/opencloud/pkg/config"
"github.com/thejerf/suture/v4"
)
// SutureService allows for the settings command to be embedded and supervised by a suture supervisor tree.
type SutureService struct {
exec func(ctx context.Context) error
}
// NewSutureServiceBuilder creates a new suture service
func NewSutureServiceBuilder(f func(context.Context, *occfg.Config) error) func(*occfg.Config) suture.Service {
return func(cfg *occfg.Config) suture.Service {
return SutureService{
exec: func(ctx context.Context) error {
return f(ctx, cfg)
},
}
}
}
// Serve to fullfil Server interface
func (s SutureService) Serve(ctx context.Context) error {
return s.exec(ctx)
}