Magician 1.1.16 is released, the handler adopts annotation configuration
From the day of its birth, Magician has been positioned as a network programming package. Although it belongs to the application layer, it is biased towards the bottom layer. In the hands of users, they generally assume the role of the kernel, whose main responsibility is to be responsible for network communications.
Due to the characteristics of the bottom layer, such problems often occur during use. After we created a TCP service
If you need to add a handler, you have to change this part of the code to make it like this
If you need WebSocket, you have to change it to this
The steps of creating a service and the steps of creating a handler are too tightly coupled. If you use this project purely, the problem is not big, but if you use this project as the core of another project, the problem will be very obvious, because in this scenario The code for creating a service is usually encapsulated separately. If the encapsulated code is changed frequently, there will be certain security risks.
So in 1.1.16 we solved this problem.
We use annotations to define a handler
When creating a service, you only need to specify a scan range
In this case, if you need to add a handler, you don't need to change this code.
For example, add a TCPHandler
Add a WebSocketHandler
Doing so will completely decouple. Creating a service is purely creating a service, and creating a handler is purely creating a handler. There is no strong connection between the two.
In addition to Magician, these components have also been upgraded
Magician-Web component, Martian component. The upgrade points of these two components are mainly changed to match Magician's changes. And it brings a new feature to Martian: it can easily support WebSocket.
Magician's performance test
The TFB test result reached 150,000 requests per second.
Project website: http://magician-io.com
版权声明: 本文为 InfoQ 作者【贝克街的天才】的原创文章。
原文链接:【http://xie.infoq.cn/article/7bf029b12fd1907e600d38294】。
本文遵守【CC-BY 4.0】协议,转载请保留原文出处及本版权声明。
评论