Probas.Ocelot.Provider.Nacos
1.0.1
dotnet add package Probas.Ocelot.Provider.Nacos --version 1.0.1
NuGet\Install-Package Probas.Ocelot.Provider.Nacos -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Probas.Ocelot.Provider.Nacos" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Probas.Ocelot.Provider.Nacos --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Probas.Ocelot.Provider.Nacos, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Probas.Ocelot.Provider.Nacos as a Cake Addin
#addin nuget:?package=Probas.Ocelot.Provider.Nacos&version=1.0.1
// Install Probas.Ocelot.Provider.Nacos as a Cake Tool
#tool nuget:?package=Probas.Ocelot.Provider.Nacos&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Probas.Ocelot.Provider.Nacos
介绍
Ocelot 集成 Nacos 注册中心组件
软件架构
软件架构说明
安装Nuget包
dotnet add package Probas.Ocelot.Provider.Nacos
使用说明(配置)
- 在
Startup.cs
进行如下配置
public void ConfigureServices(IServiceCollection services)
{
// 从配置文件读取Nacos相关配置
// 默认会使用JSON解析器来解析存在Nacos Server的配置
services.AddOcelot().AddNacos();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
// 使用Ocelot
app.UseOcelot();
}
- 修改
appsettings.json
{
"nacos": {
"ServerAddresses": [ "http://localhost:8848" ],
"DefaultTimeOut": 15000,
"ListenInterval": 1000,
"ServiceName": "NacosGateway",
"GroupName": "Sample",
"Namespace": "",
"NamingUseRpc": false
},
// 转发路由,数组中的每个元素都是某个服务的一组路由转发规则
"Routes": [
{
// 用于服务发现的名称,也就是注册到nacos上的名称 格式:GroupName@@ServiceName(GroupName默认则直接填服务名称)
"ServiceName": "Sample@@SampleService",
// Uri方案,http、https
"DownstreamScheme": "http",
// 下游(服务提供方)服务路由模板
"DownstreamPathTemplate": "/api/{address}",
// 上游(客户端,服务消费方)请求路由模板
"UpstreamPathTemplate": "/gw/{address}",
"UpstreamHttpMethod": [ "Get", "Post" ],
"LoadBalancerOptions": {
"Type": "RoundRobin" //轮询
},
"UseServiceDiscovery": true
}
],
"GlobalConfiguration": {
"ServiceDiscoveryProvider": {
"Type": "Nacos"
}
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net5.0
- nacos-sdk-csharp.AspNetCore (>= 1.1.0)
- Ocelot (>= 17.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Ocelot 集成 Nacos 注册中心组件