valyala/fasthttp

use tcpKeepaliveListener and reuseport together

已关闭

#1,320 创建于 2022年6月14日

 (3 条评论) (0 个反应) (0 位负责人)Go (1,755 个派生)batch import
enhancementhelp wanted

仓库指标

星标
 (21,741 个星标)
PR 合并指标
 (平均合并 3天) (30 天内合并 44 个 PR)

描述

I need the functionality of both tcpKeepaliveListener and reuseport. something like this:

func ListenAndServe() error {
	s := &fasthttp.Server{
		Handler: handler,
		TCPKeepalive: true,
		TCPKeepalivePeriod: 30 * time.Second,
	}
	ln, err := reuseport.Listen("tcp4", ":8080")
	if err != nil {
		return err
	}
	if tcpln, ok := ln.(*net.TCPListener); ok {
		return s.Serve(tcpKeepaliveListener{
			TCPListener:     tcpln,
			keepalive:       s.TCPKeepalive,
			keepalivePeriod: s.TCPKeepalivePeriod,
		})
	}
	return s.Serve(ln)
}

is there a reason why tcpKeepaliveListener is private? is there another way to have both functionalities that I'm missing here? thanks a lot

贡献者指南