nsq源码分析(2):nsqlookup之http服务

xiaoxiao2021-02-28  125

nsq源码分析(2):nsqlookup之http服务

nsqlookup使用了httprouter高性能http请求路由库

httprouter的路由信息

nsqlookupd/nsqlookupd.go

// 启动http服务 httpListener, err := net.Listen("tcp", l.opts.HTTPAddress) if err != nil { l.logf("FATAL: listen (%s) failed - %s", l.opts.HTTPAddress, err) os.Exit(1) } l.Lock() l.httpListener = httpListener l.Unlock() httpServer := newHTTPServer(ctx) // 封装的waitGroup,内部使用goroutine启动该服务,使用waitGroup守护改协程直到退出 l.waitGroup.Wrap(func() { http_api.Serve(httpListener, httpServer, "HTTP", l.opts.Logger) })

在newHTTPServer函数中注册了所有路由信息

待更新…

转载请注明原文地址: https://www.6miu.com/read-49339.html

最新回复(0)