This is an automated email from the ASF dual-hosted git repository.
xiaoyu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/shenyu-client-dotnet.git
The following commit(s) were added to refs/heads/main by this push:
new e2882cf [ISSUE #34] Document about http, zookeeper, consul and nacos
registration (#35)
e2882cf is described below
commit e2882cf481a7fb118206f78e00c8d94b76c287a7
Author: Han Gao <[email protected]>
AuthorDate: Mon Aug 15 16:06:25 2022 +0800
[ISSUE #34] Document about http, zookeeper, consul and nacos registration
(#35)
* Document about http, zookeeper, consul and nacos registration
* add condition for skip
---
.github/workflows/ci.yml | 2 +
.github/workflows/integration-test.yml | 4 ++
README.md | 85 +++++++++++++---------------------
docs/consul_registration.md | 72 ++++++++++++++++++++++++++++
docs/http_registration.md | 72 ++++++++++++++++++++++++++++
docs/nacos_registration.md | 74 +++++++++++++++++++++++++++++
docs/zookeeper_registration.md | 70 ++++++++++++++++++++++++++++
7 files changed, 325 insertions(+), 54 deletions(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index e2a2f07..20d60f9 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -40,10 +40,12 @@ jobs:
submodules: true
- name: Set Skip Env Var
uses: ./.github/actions/skip-ci
+
- name: Setup .NET Core SDK
uses: actions/[email protected]
with:
dotnet-version: ${{ matrix.dotnet }}
+
- name: Build with dotnet
if: env.SKIP_CI != 'true'
run: dotnet build --configuration Release
diff --git a/.github/workflows/integration-test.yml
b/.github/workflows/integration-test.yml
index 27f81d7..d66f2dc 100644
--- a/.github/workflows/integration-test.yml
+++ b/.github/workflows/integration-test.yml
@@ -40,6 +40,7 @@ jobs:
uses: ./.github/actions/skip-ci
- name: Setup .NET Core SDK
+ if: env.SKIP_CI != 'true'
uses: actions/[email protected]
with:
dotnet-version: 5.0.406
@@ -49,15 +50,18 @@ jobs:
run: dotnet build --configuration Release
- name: Build docker image for dotnet example
+ if: env.SKIP_CI != 'true'
run: |
cd ./examples/AspNetCoreExample/
docker build -t dotnet-example .
- name: Start Docker Compose
+ if: env.SKIP_CI != 'true'
run: docker-compose -f ./build/docker-compose-${{ matrix.case }}.yml
up -d
# replace with check health step
- name: Run tests
+ if: env.SKIP_CI != 'true'
run: |
sleep 30s
cd client/Tests/Apache.ShenYu.IntegrationTests
diff --git a/README.md b/README.md
index f6af550..ac06847 100644
--- a/README.md
+++ b/README.md
@@ -1,73 +1,50 @@
-# Shenyu .NET client
+# ShenYu .NET client
[](https://github.com/apache/incubator-shenyu-client-dotnet/actions)
[](https://app.codecov.io/gh/apache/incubator-shenyu-client-dotnet?branch=main)
-## Getting Started
+ShenYu .NET client can help you register your ASP.NET Core applications into
ShenYu, similar with Java client. It supports below registration type,
-### ASP.NET Core project
+- http registration
+- zookeeper registration
+- nacos registration
+- consul registration
-For ASP.NET Core project, we can refer to the example code at
`examples/AspNetCoreExample`. What you need to do is quite
-simple and straightforward.
+## Getting Started
-1. add the Shenyu ASP.NET Core dependency into project.
+Please visit related document to start to start.
-```shell
-dotnet add package <todo>
-```
+For http registration, please visit [HTTP
Registration](./docs/http_registration.md).
-2. in `Startup.ConfigureServices` method, add the `ShenyuRegister` service.
+For zookeeper registration, please visit [Zookeeper
Registration](./docs/zookeeper_registration.md).
-```c#
-public void ConfigureServices(IServiceCollection services)
-{
- ...
- services.AddShenyuRegister(this.Configuration);
- ...
-}
-```
+For consul registration, please visit [Consul
Registration](./docs/consul_registration.md).
-3. set your `Shenyu` configurations in `appsettings.json`.
+For nacos registration, please visit [Nacos
Registration](./docs/nacos_registration.md).
-```json
-{
- "Shenyu": {
- "Register": {
- "ServerList": "http://localhost:9095",
- "Props": {
- "UserName": "<your_admin_user>",
- "Password": "<your_admin_password>"
- }
- },
- "Client": {
- "AppName": "dotnet-example",
- "ContextPath": "/dotnet",
- "IsFull": false,
- "ClientType": "http"
- }
- }
-}
-```
+## Attributes
-4. enable calling via ip.
+You can use `ShenyuClient` attribute to register your APIs.
-When running on your local machine, ASP.NET Core service can only be called
from `localhost`. To enable calling by IP, you can replace
`https://localhost:{port};http://localhost:{port}` with
`https://*:{port};http://*:{port}` by one of the following ways.
+e.g. add `ShenyuClient` attribute in class as route prefix.
-- Setting in `launchSettings.json`. Replace for `applicationUrl` field.
-- Setting by environment variables `ASPNETCORE_URLS`. e.g. `ASPNETCORE_URLS
"http://*:5000"`
-- Adding `--urls` when start. e.g. `dotnet run --urls
"https://*:5001;http://*:5000"`
-- Setting progratically by `UseUrls()` in `Program.cs`.
+```csharp
+[ShenyuClient("/test/**")]
+public class TestController {
+ ...
+}
+```
-e.g.
+e.g. add `ShenyuClient` attribute in method as route path. The final route
path will be `/test/hello` for this endpoint.
```csharp
-public static IHostBuilder CreateHostBuilder(string[] args) =>
- Host.CreateDefaultBuilder(args)
- .ConfigureWebHostDefaults(webBuilder =>
- {
- webBuilder.UseStartup<Startup>();
- webBuilder.UseUrls("http://*:5000", "https://*:5001");
- });
+[ShenyuClient("/test")]
+public class TestController {
+ [ShenyuClient("hello")]
+ public IEnumerable<WeatherForecast> GetTest()
+ {
+ ...
+ }
+ ...
+}
```
-
-That's all! After finished above steps, you can just start your project and
you can visit `shenyu-admin` portal to see the APIs have been registered in
Shenyu.
diff --git a/docs/consul_registration.md b/docs/consul_registration.md
new file mode 100644
index 0000000..385ee7f
--- /dev/null
+++ b/docs/consul_registration.md
@@ -0,0 +1,72 @@
+# HTTP Registration get start
+
+## ASP.NET Core project
+
+For ASP.NET Core project, we can refer to the example code at
`examples/AspNetCoreExample`. What you need to do is quite
+simple and straightforward.
+
+1. add the Shenyu ASP.NET Core dependency into project.
+
+```shell
+dotnet add package <todo-shenyu-asp.net-core package>
+```
+
+2. in `Startup.ConfigureServices` method, add the `ShenyuRegister` service.
+
+```c#
+public void ConfigureServices(IServiceCollection services)
+{
+ ...
+ services.AddShenyuRegister(this.Configuration);
+ ...
+}
+```
+
+3. set your `Shenyu` configurations in `appsettings.json`.
+
+```json
+{
+ "Shenyu": {
+ "Register": {
+ "RegisterType": "consul",
+ "ServerList": "localhost:8500",
+ "Props": {
+ "Id": "shenyuAdmin",
+ "Name": "shenyuAdmin",
+ "Tags": "test1,test2",
+ "Port": 8500
+ }
+ },
+ "Client": {
+ "AppName": "dotnet-example",
+ "ContextPath": "/dotnet",
+ "IsFull": false,
+ "ClientType": "http"
+ }
+ }
+}
+```
+
+4. enable calling via ip.
+
+When running on your local machine, ASP.NET Core service can only be called
from `localhost`. To enable calling by IP,
+you can replace `https://localhost:{port};http://localhost:{port}` with
`https://*:{port};http://*:{port}`
+
+Setting by environment variables `ASPNETCORE_URLS`. e.g. `ASPNETCORE_URLS
"http://*:5000"`
+
+```shell
+export ASPNETCORE_URLS=http://+:5000
+```
+
+5. start the application.
+
+That's all! After finished above steps, you can start your project in IDE or
below commands and you can
+visit `shenyu-admin` portal to see the APIs have been registered in Shenyu.
+
+```shell
+# build project
+dotnet build --configuration Release
+# start project
+cd examples/AspNetCoreExample/bin/Release/netcoreapp3.1
+dotnet AspNetCoreExample.dll
+```
diff --git a/docs/http_registration.md b/docs/http_registration.md
new file mode 100644
index 0000000..caba073
--- /dev/null
+++ b/docs/http_registration.md
@@ -0,0 +1,72 @@
+# HTTP Registration get start
+
+## ASP.NET Core project
+
+For ASP.NET Core project, we can refer to the example code at
`examples/AspNetCoreExample`. What you need to do is quite
+simple and straightforward.
+
+1. add the Shenyu ASP.NET Core dependency into project.
+
+```shell
+dotnet add package <todo-shenyu-asp.net-core package>
+```
+
+2. in `Startup.ConfigureServices` method, add the `ShenyuRegister` service.
+
+```c#
+public void ConfigureServices(IServiceCollection services)
+{
+ ...
+ services.AddShenyuRegister(this.Configuration);
+ ...
+}
+```
+
+3. set your `Shenyu` configurations in `appsettings.json`.
+
+```json
+{
+ "Shenyu": {
+ "Register": {
+ "RegisterType": "http",
+ "ServerList": "http://localhost:9095",
+ "Props": {
+ // your admin user name
+ "UserName": "admin,
+ // your admin password
+ "Password": "123456"
+ }
+ },
+ "Client": {
+ "AppName": "dotnet-example",
+ "ContextPath": "/dotnet",
+ "IsFull": false,
+ "ClientType": "http"
+ }
+ }
+}
+```
+
+4. enable calling via ip.
+
+When running on your local machine, ASP.NET Core service can only be called
from `localhost`. To enable calling by IP,
+you can replace `https://localhost:{port};http://localhost:{port}` with
`https://*:{port};http://*:{port}`
+
+Setting by environment variables `ASPNETCORE_URLS`. e.g. `ASPNETCORE_URLS
"http://*:5000"`
+
+```shell
+export ASPNETCORE_URLS=http://+:5000
+```
+
+5. start the application.
+
+That's all! After finished above steps, you can start your project in IDE or
below commands and you can
+visit `shenyu-admin` portal to see the APIs have been registered in Shenyu.
+
+```shell
+# build project
+dotnet build --configuration Release
+# start project
+cd examples/AspNetCoreExample/bin/Release/netcoreapp3.1
+dotnet AspNetCoreExample.dll
+```
diff --git a/docs/nacos_registration.md b/docs/nacos_registration.md
new file mode 100644
index 0000000..30d5584
--- /dev/null
+++ b/docs/nacos_registration.md
@@ -0,0 +1,74 @@
+# HTTP Registration get start
+
+## ASP.NET Core project
+
+For ASP.NET Core project, we can refer to the example code at
`examples/AspNetCoreExample`. What you need to do is quite
+simple and straightforward.
+
+1. add the Shenyu ASP.NET Core dependency into project.
+
+```shell
+dotnet add package <todo-shenyu-asp.net-core package>
+```
+
+2. in `Startup.ConfigureServices` method, add the `ShenyuRegister` service.
+
+```c#
+public void ConfigureServices(IServiceCollection services)
+{
+ ...
+ services.AddShenyuRegister(this.Configuration);
+ ...
+}
+```
+
+3. set your `Shenyu` configurations in `appsettings.json`.
+
+```json
+{
+ "Shenyu": {
+ "Register": {
+ "RegisterType": "nacos",
+ "ServerList": "localhost:8848",
+ "Props": {
+ // your nacos user name
+ "UserName": "nacos",
+ // your nacos password
+ "Password": "nacos",
+ // align with the namespace set in admin project
+ "Namespace": "ShenyuRegisterCenter"
+ }
+ },
+ "Client": {
+ "AppName": "dotnet-example",
+ "ContextPath": "/dotnet",
+ "IsFull": false,
+ "ClientType": "http"
+ }
+ }
+}
+```
+
+4. enable calling via ip.
+
+When running on your local machine, ASP.NET Core service can only be called
from `localhost`. To enable calling by IP,
+you can replace `https://localhost:{port};http://localhost:{port}` with
`https://*:{port};http://*:{port}`
+
+Setting by environment variables `ASPNETCORE_URLS`. e.g. `ASPNETCORE_URLS
"http://*:5000"`
+
+```shell
+export ASPNETCORE_URLS=http://+:5000
+```
+
+5. start the application.
+
+That's all! After finished above steps, you can start your project in IDE or
below commands and you can
+visit `shenyu-admin` portal to see the APIs have been registered in Shenyu.
+
+```shell
+# build project
+dotnet build --configuration Release
+# start project
+cd examples/AspNetCoreExample/bin/Release/netcoreapp3.1
+dotnet AspNetCoreExample.dll
+```
diff --git a/docs/zookeeper_registration.md b/docs/zookeeper_registration.md
new file mode 100644
index 0000000..07d76ee
--- /dev/null
+++ b/docs/zookeeper_registration.md
@@ -0,0 +1,70 @@
+# HTTP Registration get start
+
+## ASP.NET Core project
+
+For ASP.NET Core project, we can refer to the example code at
`examples/AspNetCoreExample`. What you need to do is quite
+simple and straightforward.
+
+1. add the Shenyu ASP.NET Core dependency into project.
+
+```shell
+dotnet add package <todo-shenyu-asp.net-core package>
+```
+
+2. in `Startup.ConfigureServices` method, add the `ShenyuRegister` service.
+
+```c#
+public void ConfigureServices(IServiceCollection services)
+{
+ ...
+ services.AddShenyuRegister(this.Configuration);
+ ...
+}
+```
+
+3. set your `Shenyu` configurations in `appsettings.json`.
+
+```json
+{
+ "Shenyu": {
+ "Register": {
+ "RegisterType": "zookeeper",
+ "ServerList": "localhost:2181",
+ "Props": {
+ // 3000 ms by default
+ "SessionTimeout": 60000
+ }
+ },
+ "Client": {
+ "AppName": "dotnet-example",
+ "ContextPath": "/dotnet",
+ "IsFull": false,
+ "ClientType": "http"
+ }
+ }
+}
+```
+
+4. enable calling via ip.
+
+When running on your local machine, ASP.NET Core service can only be called
from `localhost`. To enable calling by IP,
+you can replace `https://localhost:{port};http://localhost:{port}` with
`https://*:{port};http://*:{port}`
+
+Setting by environment variables `ASPNETCORE_URLS`. e.g. `ASPNETCORE_URLS
"http://*:5000"`
+
+```shell
+export ASPNETCORE_URLS=http://+:5000
+```
+
+5. start the application.
+
+That's all! After finished above steps, you can start your project in IDE or
below commands and you can
+visit `shenyu-admin` portal to see the APIs have been registered in Shenyu.
+
+```shell
+# build project
+dotnet build --configuration Release
+# start project
+cd examples/AspNetCoreExample/bin/Release/netcoreapp3.1
+dotnet AspNetCoreExample.dll
+```