Skip to content

Conversation

@hhuang1231
Copy link
Contributor

Fixes #549

Motivation

  • Unified TCP and HTTP code styles
  • Optimize code encapsulation and reduce coupling
  • More careful subcontracting and naming enhances readability

boot

Firstly, I divided the server into three layers:

  1. The most basic layer is AbstractRemotingServer . It leverages Netty for the most basic communication server.
  2. Then there are the protocol-layer servers that enable the runtime module to run simply, such as AbstractTcpServer and AbstractHttpServer.
  3. Finally, there are EventMeshXxxServer that integrate multiple capabilities (typically a manager that assembles the capabilities to enhance the server) , such as EventMeshTCPServer and 'EventMeshHTTPServer`.

In my opinion, the most important part of the runtime module is the "processor" . The main component of the second-tier server is the "processor" . That is, declare the "processor" required for registration in the Layer 2 server AbstractXXXServer to build the layer server.

In layer 3 server, I prefer pluggable plug-in design. That is, in the process of extending the "processor" , if there is a function that requires other modules, add the manager of the corresponding function in this layer. The processor then retrieves the corresponding manager through the EventMeshXxxServer instance.

For example :

  • Registry is provided for cluster deployment of eventmesh servers.
  • The rest of the modules, such as 'security' and 'metric' , can be inserted into the corresponding manager in the tier 3 server.

Modifications

boot:

  • So I implemented TCP's second-tier server, AbstractTcpServer . I've used all of Netty's required handlers as AbstracTcpServer internal classes to better manage this tier of servers.
  • And registered "processor" in the third-tier server juts like EventMeshHTTPServer
  • I think the creation and use of threads is actually the basis for the server to run, so I put it on the second-tier server and used an interface ThreadPoolGroup to normalize it, the implementation classes of this interface can assemble the required thread pool.

core

  • Convert a task under the TCP protocol to a processor

Documentation

  • Does this pull request introduce a new feature? (yes / no)
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
  • If a feature is not applicable for documentation, explain why?
  • If a feature is not documented yet in this PR, please create a followup issue for adding the documentation

@hhuang1231 hhuang1231 marked this pull request as ready for review August 5, 2023 03:30
@hhuang1231 hhuang1231 changed the title refactor: enhance http and tcp server style [ISSUE #549] Unify request handler code style of tcp and http protocol Aug 5, 2023
@codecov
Copy link

codecov bot commented Aug 5, 2023

Codecov Report

Merging #4333 (ff3296a) into master (3678c23) will increase coverage by 0.05%.
The diff coverage is 0.88%.

❗ Current head ff3296a differs from pull request most recent head 88c3114. Consider uploading reports for the commit 88c3114 to get more accurate results

@@             Coverage Diff              @@
##             master    #4333      +/-   ##
============================================
+ Coverage     17.82%   17.88%   +0.05%     
- Complexity     1514     1516       +2     
============================================
  Files           604      603       -1     
  Lines         25559    25493      -66     
  Branches       2400     2377      -23     
============================================
+ Hits           4556     4559       +3     
+ Misses        20564    20496      -68     
+ Partials        439      438       -1     
Files Changed Coverage Δ
...e/admin/handler/RedirectClientByIpPortHandler.java 34.04% <0.00%> (ø)
...dmin/handler/RedirectClientBySubSystemHandler.java 9.09% <0.00%> (ø)
.../runtime/admin/handler/RejectAllClientHandler.java 12.50% <0.00%> (ø)
...ime/admin/handler/RejectClientByIpPortHandler.java 9.30% <0.00%> (ø)
.../admin/handler/RejectClientBySubSystemHandler.java 8.33% <0.00%> (ø)
...ntmesh/runtime/admin/handler/TCPClientHandler.java 4.54% <0.00%> (-0.06%) ⬇️
...he/eventmesh/runtime/boot/EventMeshHTTPServer.java 0.68% <0.00%> (+0.16%) ⬆️
...eventmesh/runtime/boot/EventMeshHttpBootstrap.java 0.00% <0.00%> (ø)
...apache/eventmesh/runtime/boot/EventMeshServer.java 0.00% <0.00%> (ø)
...che/eventmesh/runtime/boot/EventMeshTCPServer.java 0.84% <0.00%> (+0.27%) ⬆️
... and 23 more

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@harshithasudhakar
Copy link
Member

LGTM

@qqeasonchen
Copy link
Contributor

@silentchildh please fix the conflicts.

@hhuang1231
Copy link
Contributor Author

@qqeasonchen @harshithasudhakar PTAL

@xwm1992 xwm1992 merged commit af53e7a into apache:master Aug 28, 2023
@hhuang1231 hhuang1231 deleted the style branch November 16, 2023 16:00
xuhongjia pushed a commit to Deckers-Ohana/eventmesh that referenced this pull request Mar 13, 2025
…rotocol (apache#4333)

* refactor: enhance http and tcp server style

* fix: create trace-plugin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement]Unify request handler code style of tcp and http protocol

5 participants