SkillAgentSearch skills...

EasyRpc

EasyRpc

Install / Use

/learn @zhongzepeng/EasyRpc
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

EasyRpc

实现简单的Rpc远程调用

  • 使用DispatchProxy生成动态代理
  • 基于System.IO.Pipelines 实现命令传输
  • 使用System.Text.JSON 作为序列化工具
  • 基于 Microsoft.Extensions.DependencyInjection 的简单服务注册和服务查找

使用方法

  • 服务端
    •        var serviceAssembly = Assembly.GetAssembly(typeof(IUserService));
             serviceCollection.AddRpcServer(configuration, serviceAssembly);
             var serviceProvider = serviceCollection.BuildServiceProvider();
             var server = serviceProvider.GetService<RpcServer>();
             await server.StartAsync();
      
  • 客户端
    •        var serviceProvider = serviceCollection.BuildServiceProvider();
             var client = serviceProvider.GetService<RpcClient>();
             await client.StartAsync();
      
             var userService = client.CreateProxy<IUserService>();
             for (int i = 0; i < 100; i++)
             {
                 var result = userService.GetUserNameById(new TestParam { Id = 1.ToString() });
                 Console.WriteLine($"{result}----{i}");
             }
      
View on GitHub
GitHub Stars6
CategoryDevelopment
Updated1y ago
Forks1

Languages

C#

Security Score

50/100

Audited on Aug 22, 2024

No findings