From a59b13a21a5f9169a6b462349ab75e5b0dd64b14 Mon Sep 17 00:00:00 2001 From: Paul Hewlett Date: Mon, 25 Sep 2023 14:35:32 +0100 Subject: [PATCH] fixup! fixup! fixup! fixup! Generic listener management --- startup/listener.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/startup/listener.go b/startup/listener.go index f100bc3..afd03c1 100644 --- a/startup/listener.go +++ b/startup/listener.go @@ -35,12 +35,6 @@ func WithListener(h Listener) ListenersOption { } } -func WithListeners(h []Listener) ListenersOption { - return func(l *Listeners) { - l.listeners = append(l.listeners, h...) - } -} - func NewListeners(log Logger, name string, opts ...ListenersOption) Listeners { l := Listeners{log: log, name: name} for _, opt := range opts { @@ -53,6 +47,10 @@ func (l *Listeners) String() string { return l.name } +func (l *Listeners) AddListener(h Listener) { + l.listeners = append(l.listeners, h) +} + func (l *Listeners) Listen() error { ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)