Skip to content

Commit 5ed944d

Browse files
butonicrhafer
authored andcommitted
fix service name in suture logs
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
1 parent a7defc2 commit 5ed944d

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

opencloud/pkg/runtime/service/service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func NewService(ctx context.Context, options ...Option) (*Service, error) {
124124
if s.Services[priority] == nil {
125125
s.Services[priority] = make(serviceFuncMap)
126126
}
127-
s.Services[priority][name] = NewSutureServiceBuilder(exec)
127+
s.Services[priority][name] = NewSutureServiceBuilder(name, exec)
128128
}
129129

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

317317
// populate optional services
318318
areg := func(name string, exec func(context.Context, *occfg.Config) error) {
319-
s.Additional[name] = NewSutureServiceBuilder(exec)
319+
s.Additional[name] = NewSutureServiceBuilder(name, exec)
320320
}
321321
areg(opts.Config.Antivirus.Service.Name, func(ctx context.Context, cfg *occfg.Config) error {
322322
cfg.Antivirus.Context = ctx

opencloud/pkg/runtime/service/sutureservice.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@ import (
1010
// SutureService allows for the settings command to be embedded and supervised by a suture supervisor tree.
1111
type SutureService struct {
1212
exec func(ctx context.Context) error
13+
name string
1314
}
1415

1516
// NewSutureServiceBuilder creates a new suture service
16-
func NewSutureServiceBuilder(f func(context.Context, *occfg.Config) error) func(*occfg.Config) suture.Service {
17+
func NewSutureServiceBuilder(name string, f func(context.Context, *occfg.Config) error) func(*occfg.Config) suture.Service {
1718
return func(cfg *occfg.Config) suture.Service {
1819
return SutureService{
1920
exec: func(ctx context.Context) error {
2021
return f(ctx, cfg)
2122
},
23+
name: name,
2224
}
2325
}
2426
}
@@ -27,3 +29,8 @@ func NewSutureServiceBuilder(f func(context.Context, *occfg.Config) error) func(
2729
func (s SutureService) Serve(ctx context.Context) error {
2830
return s.exec(ctx)
2931
}
32+
33+
// String to fullfil fmt.Stringer interface, used to log the service name
34+
func (s SutureService) String() string {
35+
return s.name
36+
}

0 commit comments

Comments
 (0)