Netty HTTP计数请求 [英] Netty http count requests
问题描述
我正在使用Netty编写简单的hhtp服务器.
I am writing simple hhtp server using Netty.
如何使用Netty计算所有请求(连接)和活动连接? 我正在使用示例 https://github.com/netty/netty/tree/4.0/example/src/main/java/io/netty/example/http 并尝试计算我的请求.我应该使用自己的计数器"来执行此操作还是要使用任何可用的计数功能?
How can i count all requests (connections) and active connections using Netty? I am using example https://github.com/netty/netty/tree/4.0/example/src/main/java/io/netty/example/http and trying to count my requests. Should i use my own 'counter' to do that or any ready functions to count?
此外,我需要存储一些数据(例如,每个请求被访问了多少次),最好的存储方式是什么?存储在何处?
Also, i need to store some data (for example how many times each request were accessed), what is the best way to store that and where?
推荐答案
您需要将自己的计数器实现到用于处理http请求的处理程序中,或为此目的在管道上添加的一个特定处理程序中.我更喜欢第二种选择,以更好地分离管道的角色.此外,您可以通过删除管道的特定处理程序来停止计数.
You need to implement your own counter, into the handler which handles the http request or into one specific handler added on pipeline for this purpose. I prefer the second option to better separate role of pipeline. Moreover, you can just stop counting by removing the specific handler of pipeline.
这篇关于Netty HTTP计数请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!