diff --git a/message/infrastructure/http/subscriber.go b/message/infrastructure/http/subscriber.go index 58379f763..1943cd035 100644 --- a/message/infrastructure/http/subscriber.go +++ b/message/infrastructure/http/subscriber.go @@ -33,7 +33,7 @@ func NewSubscriber(addr string, unmarshalMessageFunc UnmarshalMessageFunc, logge s, logger, unmarshalMessageFunc, - make([]chan *message.Message, 1), + make([]chan *message.Message, 0), &sync.Mutex{}, false, }, nil @@ -84,17 +84,19 @@ func (s *Subscriber) RunHTTPServer() error { return s.server.ListenAndServe() } -func (s Subscriber) Close() error { +func (s *Subscriber) Close() error { if s.closed { return nil } s.closed = true - defer func() { - for _, ch := range s.outputChannels { - close(ch) - } - }() + if err := s.server.Close(); err != nil { + return err + } + + for _, ch := range s.outputChannels { + close(ch) + } - return s.server.Close() + return nil }