update Listener interface

This commit is contained in:
ginuerzh
2022-03-15 10:23:57 +08:00
parent 42f72adde0
commit 2e40afe535
12 changed files with 73 additions and 279 deletions

View File

@ -71,7 +71,7 @@ func (s *service) Serve() error {
var tempDelay time.Duration
for {
conn, e := s.listener.Accept()
conn, md, e := s.listener.Accept()
if e != nil {
if ne, ok := e.(net.Error); ok && ne.Temporary() {
if tempDelay == 0 {
@ -108,7 +108,11 @@ func (s *service) Serve() error {
metrics.RequestSeconds(s.name).Observe(time.Since(start).Seconds())
}()
if err := s.handler.Handle(context.Background(), conn); err != nil {
if err := s.handler.Handle(
context.Background(),
conn,
handler.MetadataHandleOption(md),
); err != nil {
s.options.logger.Error(err)
metrics.HandlerErrors(s.name).Inc()
}