From 6c3e187d1ddc8579a13c07d6cbd9cdfa174ec00e Mon Sep 17 00:00:00 2001 From: greatroar <61184462+greatroar@users.noreply.github.com> Date: Mon, 25 Jan 2021 16:27:17 +0100 Subject: [PATCH] lib/svcutil: Simplify doneService (#7303) OnSupervisorDone no longer allocates. Co-authored-by: greatroar <@> --- lib/svcutil/svcutil.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/svcutil/svcutil.go b/lib/svcutil/svcutil.go index eee33352e..3327c7014 100644 --- a/lib/svcutil/svcutil.go +++ b/lib/svcutil/svcutil.go @@ -144,19 +144,17 @@ func (s *service) String() string { } -type doneService struct { - fn func() -} +type doneService func() -func (s *doneService) Serve(ctx context.Context) error { +func (fn doneService) Serve(ctx context.Context) error { <-ctx.Done() - s.fn() + fn() return nil } // OnSupervisorDone calls fn when sup is done. func OnSupervisorDone(sup *suture.Supervisor, fn func()) { - sup.Add(&doneService{fn}) + sup.Add(doneService(fn)) } func SpecWithDebugLogger(l logger.Logger) suture.Spec {