# surging **Repository Path**: hfting/surging ## Basic Information - **Project Name**: surging - **Description**: surging 是一个分布式微服务引擎,提供高性能RPC远程服务调用,服务引擎支持http、TCP、WS、Mqtt协议,采用Zookeeper、Consul作为surging服务的注册中心,集成了哈希一致性,随机,轮询、压力最小优先作为负载均衡的算法,RPC集成采用的是netty框架,采用异步传输 - **Primary Language**: C# - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 2 - **Created**: 2019-11-19 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # surging                     [中文](https://github.com/dotnetcore/surging/blob/master/README.md) [![Member project of .NET Core Community](https://img.shields.io/badge/member%20project%20of-NCC-9e20c9.svg)](https://github.com/dotnetcore) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://mit-license.org/) # surging is a distributed micro service framework that provides high-performance RPC remote service calls, using Zookeeper, Consul as the registration center for surging services, integrating hash, random, polling as a load balancing algorithm, RPC integration using the netty framework, Using asynchronous transmission.
Start configuration:
```c# var host = new ServiceHostBuilder() .RegisterServices(builder => { builder.AddMicroService(option => { option.AddServiceRuntime();// // option.UseZooKeeperManager(new ConfigInfo("127.0.0.1:2181")); //Using a Zookeeper management option.UseConsulManager(new ConfigInfo("127.0.0.1:8500"));//Use the Consul management option.UseDotNettyTransport();//Use Netty transmission option.UseRabbitMQTransport();//Use the rabbitmq transmission option.AddRabbitMQAdapt();//Based on the consumption of the rabbitmq service adaptation builder.Register(p => new CPlatformContainer(ServiceLocator.Current));//Initializes the injection container }); }) .SubscribeAt() //News Feeds .UseServer("127.0.0.1", 98) //.UseServer("127.0.0.1", 98,“true”) //Automatically generate Token //.UseServer("127.0.0.1", 98,“123456789”) //Fixed password Token .UseLog4net("Configs/log4net.config") //Use log4net to generate the log .UseLog4net() //Use log4net to generate the log .UseStartup() .Build(); using (host.Run()) { Console.WriteLine($"The server startup success,{DateTime.Now}。"); } ```
Subscription function:
```c# ServiceLocator.GetService< ISubscriptionAdapt >().SubscribeAt(); ```
Increase service fault-tolerant, fault-tolerant forcibly demote demotion and service * Increase the fault tolerance strategy Injection, the local module injection:
```c# [Command(Strategy= StrategyType.Injection ,Injection = @"return null;")] ```
```C# [Command(Strategy= StrategyType.Injection ,Injection = @"return Task.FromResult(new Surging.IModuleServices.Common.Models.UserModel { Name=""fanly"", Age=18 });",InjectionNamespaces =new string[] { "Surging.IModuleServices.Common"})] ``` * Increase Injection fault-tolerant strategy, local Injection module:
```C# [Command(Strategy= StrategyType.Injection ,Injection = @"return true;")] ```
Increase the cache relegation, how to use?
Add the following features in the business interface methods
```C# [Command(Strategy= StrategyType.Failover,FailoverCluster =3,RequestCacheEnabled =true)] //RequestCacheEnabled =true Is to enable the cache ```
How to intercept access to cache?
Add the following features in the business interface methods
```C# [InterceptMethod(CachingMethod.Get, Key = "GetUser_id_{0}", Mode = CacheTargetType.Redis, Time = 480)] ```
How to intercept the delete cache?
Add the following features in the business interface methods
```C# [InterceptMethod(CachingMethod.Remove, "GetUser_id_{0}", "GetUserName_name_{0}", Mode = CacheTargetType.Redis)] ```
How to add the cache KEY
On the business model attribute to add, the following features, can support multiple
```C# [CacheKey(1)] ```
Configuring Interceptors
```C# .AddClientIntercepted(typeof(CacheProviderInterceptor)) ``` IDE:Visual Studio 2017 15.3 Preview ,vscode
The framework:.NET core 2.0
如有任何问题可以加入QQ群:542283494 Gitter:not room
[Blog]:https://www.cnblogs.com/fanliang11