Register Center Source Code Analysis of Http Register
Apache ShenYu is an asynchronous, high-performance, cross-language, responsive API gateway.
In ShenYu gateway, the registration center is used to register the client information to shenyu-admin, admin then synchronizes this information to the gateway through data synchronization, and the gateway completes traffic filtering through these data. The client information mainly includes interface information and URI information.
This article is based on
shenyu-2.5.0version for source code analysis, please refer to Client Access Principles for the introduction of the official website.
1. Registration Center Principle
When the client starts, it reads the interface information and uri information, and sends the data to shenyu-admin by the specified registration type.

The registration center in the figure requires the user to specify which registration type to use. ShenYu currently supports Http, Zookeeper, Etcd, Consul and Nacos for registration. Please refer to Client Access Configuration for details on how to configure them.
ShenYu introduces Disruptor in the principle design of the registration center, in which the Disruptor queue plays a role in decoupling data and operations, which is conducive to expansion. If too many registration requests lead to registration exceptions, it also has a data buffering role.

As shown in the figure, the registration center is divided into two parts, one is the registration center client register-client, the load processing client data reading. The other is the registration center server register-server, which is loaded to handle the server side (that is shenyu-admin) data writing. Data is sent and received by specifying the registration type.
- Client: Usually it is a microservice, which can be
springmvc,spring-cloud,dubbo,grpc, etc. register-client: register the central client, read the client interface anduriinformation.Disruptor: decoupling data from operations, data buffering role.register-server: registry server, here isshenyu-admin, receive data, write to database, send data synchronization events.- registration-type: specify the registration type, complete data registration, currently supports
Http,Zookeeper,Etcd,ConsulandNacos.
This article analyzes the use of Http for registration, so the specific processing flow is as follows.

On the client side, after the data is out of the queue, the data is transferred via http and on the server side, the corresponding interface is provided to receive the data and then write it to the queue.
2. Client Registration Process
When the client starts, it reads the attribute information according to the relevant configuration, and then writes it to the queue. Let's take the official shenyu-examples-http as an example and start the source code analysis . The official example is a microservice built by springboot. For the configuration of the registration center, please refer to the official website client access configuration .