All Projects → catcherwong → Nacos Sdk Csharp

catcherwong / Nacos Sdk Csharp

Licence: mit
🌹 nacos csharp sdk

Programming Languages

csharp
926 projects

Projects that are alternatives of or similar to Nacos Sdk Csharp

Colore
A powerful C# library for Razer Chroma's SDK
Stars: ✭ 121 (-22.93%)
Mutual labels:  sdk, netcore
Webqqwechat
webQQ和web微信相关协议的.net实现
Stars: ✭ 127 (-19.11%)
Mutual labels:  sdk, netcore
Oss.clients.sns
社交网站sdk(标准库),微信公众号(订阅号,服务号,小程序)接口sdk-包含消息回复(明文和安全模式),Oauth2.0授权等
Stars: ✭ 136 (-13.38%)
Mutual labels:  sdk, netcore
Appsflyer React Native Plugin
AppsFlyer plugin for React Native
Stars: ✭ 149 (-5.1%)
Mutual labels:  sdk
Cos Nodejs Sdk V5
腾讯云 COS Nodejs SDK(XML API)
Stars: ✭ 149 (-5.1%)
Mutual labels:  sdk
Pymedium
Unofficial Medium Python Flask API and SDK
Stars: ✭ 153 (-2.55%)
Mutual labels:  sdk
Abot
Cross Platform C# web crawler framework built for speed and flexibility. Please star this project! +1.
Stars: ✭ 1,961 (+1149.04%)
Mutual labels:  netcore
Dialogflow Ruby Client
Ruby SDK for Dialogflow
Stars: ✭ 148 (-5.73%)
Mutual labels:  sdk
Esp8266 Firmware
DeviceHive esp8266 firmware. Control hardware via clouds with DeviceHive!
Stars: ✭ 154 (-1.91%)
Mutual labels:  sdk
Javascript Sdk
Javascript SDK to communicate with Binance Chain.
Stars: ✭ 151 (-3.82%)
Mutual labels:  sdk
Openweatherplus Android
An open source weather APP for Android. 天气普拉斯Android版,自带天气数据的开源天气APP。
Stars: ✭ 153 (-2.55%)
Mutual labels:  sdk
Wechatpay Apache Httpclient
微信支付 APIv3 Apache HttpClient装饰器(decorator)
Stars: ✭ 147 (-6.37%)
Mutual labels:  sdk
Aws Sdk Perl
A community AWS SDK for Perl Programmers
Stars: ✭ 153 (-2.55%)
Mutual labels:  sdk
Jitsi Meet Sdk Samples
Jitsi Meet SDK examples (Android and iOS)
Stars: ✭ 150 (-4.46%)
Mutual labels:  sdk
Sharpbgfx
C# bindings for the bgfx graphics library
Stars: ✭ 154 (-1.91%)
Mutual labels:  netcore
Keralua
C# Native bindings of Lua 5.4 (compatible with iOS/Mac/Android/.NET/.NET Core/UWP)
Stars: ✭ 147 (-6.37%)
Mutual labels:  netcore
Formhelper
ASP.NET Core - Transform server-side validations to client-side without writing any javascript code. (Compatible with Fluent Validation)
Stars: ✭ 155 (-1.27%)
Mutual labels:  netcore
Megaapiclient
MegaApiClient is a C# .Net library to access http://mega.co.nz / http://mega.nz cloud storage and file hosting service.
Stars: ✭ 151 (-3.82%)
Mutual labels:  netcore
Fluentdispatch
🌊 .NET Standard 2.1 framework which makes easy to scaffold distributed systems and dispatch incoming load into units of work in a deterministic way.
Stars: ✭ 152 (-3.18%)
Mutual labels:  netcore
Mmalsharp
C# wrapper to Broadcom's MMAL with an API to the Raspberry Pi camera.
Stars: ✭ 152 (-3.18%)
Mutual labels:  netcore

nacos-sdk-csharp             中文

Unofficial csharp(dotnet core) implementation of nacos OpenAPI.

This project was moved to https://github.com/nacos-group/nacos-sdk-csharp

CI Build Status

Platform Build Server Master Status
Github Action Linux/Windows nacos-sdk-csharp CI

Installation

dotnet add package nacos-sdk-csharp-unofficial

Features

  • Basic OpenApi Usages
  • Integrate ASP.NET Core Configuration System
  • Service Registration and Discovery With ASP.NET Core
  • Integrate With Aliyun ACM
  • ...

Basic Usage

Simple Configuration Usage

  1. Configure in Program.cs
public static IHostBuilder CreateHostBuilder(string[] args) =>
    Host.CreateDefaultBuilder(args)
        .ConfigureAppConfiguration((context, builder) =>
        {
            var c = builder.Build();

            // read configuration from config files
            builder.AddNacosConfiguration(c.GetSection("NacosConfig"));
        })
        .ConfigureWebHostDefaults(webBuilder =>
        {
            webBuilder.UseStartup<Startup>();
        })
  1. Modify appsettings.json
{
  "NacosConfig": {
    "Optional": false,
    "DataId": "msconfigapp",
    "Group": "",
    "Tenant": "f47e0ae1-982a-4a64-aea3-52506492a3d4",
    "ServerAddresses": [ "http://localhost:8848/" ],
    "UserName": "test2",
    "Password": "123456",
    "AccessKey": "",
    "SecretKey": "",
    "EndPoint": "acm.aliyun.com"
  }
}
  1. Use via .NET Core's Way
[ApiController]
[Route("api/[controller]")]
public class ConfigController : ControllerBase
{
    private readonly IConfiguration _configuration;
    private readonly AppSettings _settings;
    private readonly AppSettings _sSettings;
    private readonly AppSettings _mSettings;
    
    public ConfigController(
        IConfiguration configuration,
        IOptions<AppSettings> options,
        IOptionsSnapshot<AppSettings> sOptions,
        IOptionsMonitor<AppSettings> _mOptions
        )
    {
        _logger = logger;
        _configuration = configuration;
        _settings = options.Value;
        _sSettings = sOptions.Value;
        _mSettings = _mOptions.CurrentValue;
    }

    [HttpGet]
    public string Get()
    {
        // ....
       
        return "ok";
    }

}

Service Registration and Discovery

  1. Service Registration

Configure in Program.cs

public class Startup
{
    public Startup(IConfiguration configuration)
    {
        Configuration = configuration;
    }

    public IConfiguration Configuration { get; }

    public void ConfigureServices(IServiceCollection services)
    {
        // ...

        services.AddNacosAspNetCore(Configuration);
    }

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        // ...
    }
}

Modify appsettings.json

"nacos": {
    "ServerAddresses": [ "http://localhost:8848" ],
    "DefaultTimeOut": 15000,
    "Namespace": "",
    "ListenInterval": 1000,
    "ServiceName": "App1"
  }
  1. Service Discovery
[Route("api/[controller]")]
[ApiController]
public class ValuesController : ControllerBase
{
    private readonly INacosServerManager _serverManager;

    public ValuesController(INacosServerManager serverManager)
    {
        _serverManager = serverManager;
    }

    [HttpGet("test")]
    public async Task<IActionResult> Test()
    {        
        // need to know the service name.
        // at this time only support random way.
        var baseUrl = await _serverManager.GetServerAsync("App2");
                    
        if(string.IsNullOrWhiteSpace(baseUrl))
        {
            return "empty";
        }

        var url = $"{baseUrl}/api/values";

        using (HttpClient client = new HttpClient())
        {
            var result = await client.GetAsync(url);
            return await result.Content.ReadAsStringAsync();
        }
    }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].