Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions opencloud/pkg/runtime/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func NewService(ctx context.Context, options ...Option) (*Service, error) {
if s.Services[priority] == nil {
s.Services[priority] = make(serviceFuncMap)
}
s.Services[priority][name] = NewSutureServiceBuilder(exec)
s.Services[priority][name] = NewSutureServiceBuilder(name, exec)
}

// nats is in priority group 0. It needs to start before all other services
Expand Down Expand Up @@ -316,7 +316,7 @@ func NewService(ctx context.Context, options ...Option) (*Service, error) {

// populate optional services
areg := func(name string, exec func(context.Context, *occfg.Config) error) {
s.Additional[name] = NewSutureServiceBuilder(exec)
s.Additional[name] = NewSutureServiceBuilder(name, exec)
}
areg(opts.Config.Antivirus.Service.Name, func(ctx context.Context, cfg *occfg.Config) error {
cfg.Antivirus.Context = ctx
Expand Down
9 changes: 8 additions & 1 deletion opencloud/pkg/runtime/service/sutureservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ import (
// 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
name string
}

// NewSutureServiceBuilder creates a new suture service
func NewSutureServiceBuilder(f func(context.Context, *occfg.Config) error) func(*occfg.Config) suture.Service {
func NewSutureServiceBuilder(name string, 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)
},
name: name,
}
}
}
Expand All @@ -27,3 +29,8 @@ func NewSutureServiceBuilder(f func(context.Context, *occfg.Config) error) func(
func (s SutureService) Serve(ctx context.Context) error {
return s.exec(ctx)
}

// String to fullfil fmt.Stringer interface, used to log the service name
func (s SutureService) String() string {
return s.name
}
Loading