1
, preface
After more than 10 days of efforts, the surging gateway has a rough prototype, the latter will continue to update and improve, please continue to pay attention to the development of the dynamic
A new version of surging has also recently been updated
Update content:
1. Extended Zookeeper Package
2. Add Service Metadata
3. Add an API Gateway
Open Source Address: https://github.com/dotnetcore/surging
2. Software Environment
Ide:visual Studio 15.3 Preview, Vscode
Framework:. NET Core 2.0
Dependent programs: Zookeepe, RABBITMQ
Vscode Technical Support:
Zhou Pine (zsbfre)
3.Zookeeper Installation
Zookeeper is a distributed Application coordination Service, is Google's chubby open source implementation, is an important component of Hadoop, CDH version of it is used for namenode coordinated control. And surging is based on zookeeper as the registration center
Installation & Configuration
The official website of Apache provides a lot of mirrors, then find the corresponding version, the latest is 3.3.6
:
Http://mirrors.cnnic.cn/apache/zookeeper/zookeeper-3.3.6/zookeeper-3.3.6.tar.gz
Install under Windows
Extract the downloaded zookeeper files to the specified directory
D:\zookeeper>
Modify the Conf to add a zoo.cfg
The contents are as follows:
# The number of milliseconds of each tick heartbeat interval milliseconds each time
ticktime=2000
# The number of ticks that initial
# Synchronization phase can take
initlimit=10
# The number of ticks that can pass between
# Sending a request and getting anacknowledgement
Synclimit=5
# The directory where the snapshot isstored. Mirrored Data location
Datadir=/tmp/zookeeper
# The port at which the clients WillConnect client connection
clientport=2181
Go to the Bin directory and start Zkserver.cmd, this script will start a Java process
D:\ZOOKEEPER>CD bin
D:\zookeeper\>
D:\zookeeper\bin >zkserver.cmd
Start the client run and see for yourself
D:\zookeeper\bin>zkcli.cmd 127.0.0.1:2181
This time zookeeper has been installed successfully,
Refer to the official documentation:
Http://zookeeper.apache.org/doc/trunk/zookeeperStarted.html
4.API Gateway
Surging's API gateway is divided into data monitoring ', service management ', data security, identity authentication, flow control, and shunt control. This section describes the following service management, and other features that will be introduced in the next few articles
Service Management
For the service we need to manage the following actions
Service machine: For the service deployment of the machine, we need the platform for management monitoring, if an exception occurs, through the API gateway to alarm
Metadata: Through metadata we can find annotations of related services, such as name, owner, update time
Related consumption: What consumer clients can call consumption through related consumption
The above operation, can effectively manage the service deployed on each machine, reduce the maintenance of human cost.
The following example shows how to use the
Add the following attribute on the business interface method
" 2017-8-11 " " fanly " " Get user ")]
Property List
Parameters |
function |
Name |
Method name |
Date |
Update Date |
Director |
Head |
Based on zookeeper configuration
. Usezookeeperroutemanager (New Configinfo ("127.0.0.1:2181"))
For the code has been completed, the API gateway can enter http://localhost:729/for access, and then you will see the following interface
6. Summary
API Gateway has a rough prototype, the following will continue to improve the API gateway, and will refactor zookeeper node management and add file configuration to replace the code. If interested please pay more attention or join QQ Group: 615562965
-API Gateway Service management based on the. NET Core MicroServices Framework