Surging is a micro-service engine that provides a lightweight, high-performance, modular RPC request pipeline. support Event-based Asynchronous Pattern and reactive programming ,The service engine supports http, TCP, WS,Grpc, Thrift,Mqtt, UDP, and DNS protocols. It uses ZooKeeper and Consul as a registry, and integrates it. Hash, random, polling, Fair Polling as a load balancing algorithm, built-in service governance to ensure reliable RPC communication, the engine contains Diagnostic, link tracking for protocol and middleware calls, and integration SkyWalking Distributed APM
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();
[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"})]
[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
[InterceptMethod(CachingMethod.Get, Key = "GetUser_id_{0}", Mode = CacheTargetType.Redis, Time = 480)]
[InterceptMethod(CachingMethod.Remove, "GetUser_id_{0}", "GetUserName_name_{0}", Mode = CacheTargetType.Redis)]
[CacheKey(1)]
.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