Stats统计topic/channel/client
Autherization
protocol.messagePump
信号处理解析参数构造NSQD对象nsqd持久化启动nsqd主线程
Send
memQ
options(ID是hostname unique的)
incomingChan
PutMessage
根据URI路由util: PostRequired装饰器xxxResponseWrapper包装器
1. 全局context对象:nsqd+logger 2. 两个httpListener分别监听HTTP和HTTPS 3. 一个TCPListener监听四层端口 4. 持久化/反持久化 5. Topic操作(线程安全的map操作): Get/GetExisting/DeleteExisting 6. 生产GUID.hex()并放入无缓冲管道
InFlightDeferred
app
router
statsd计数器循环
https
PutMessage - router - messagePump channel的Get/GetExisting/DeleteExisting 多channel时pump函数会复制消息
remote
memoryChan
waitGroupWrapper辅助
topic:messagePump
client主要维护remote的认证和计数
构造options对象
解析包头后进入protocol的IOLoop
go routine
protocol: TCP请求包的有效性校验 命令路由到正确的对象处理 形成remote可以理解的json回包 读取channel的消息发送到remote
messagePump
解析req找到所需的topic/channel/msgBody
http
requeue
queue
memoryQueue
HTTP Server承接listener和server
nsqd
diskqueue
clientMsgChan
new
diskQueue
tcp
channel:messagePump
TCP Server从listener进行accept并交给handler
nsqd.Exit()调用时所有server和idPump 会在此等待
返回默认对象
topic/channelPutMsg
GUID生成器长度16字节作为消息ID