Skip to content

Latest commit

 

History

History
137 lines (107 loc) · 4.34 KB

README.EN.md

File metadata and controls

137 lines (107 loc) · 4.34 KB

surging                     中文

Member project of .NET Core Community GitHub license

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:


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<Startup>()
               .Build();
               
           using (host.Run())
           {
               Console.WriteLine($"The server startup success,{DateTime.Now}");
           }

Subscription function:

 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:

[Command(Strategy= StrategyType.Injection ,Injection = @"return null;")]

[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:

[Command(Strategy= StrategyType.Injection ,Injection = @"return true;")] 

Increase the cache relegation, how to use?
Add the following features in the business interface methods

   [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
 [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
  [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
[CacheKey(1)]

Configuring Interceptors
 .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