在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:Thrifty开源软件地址:https://gitee.com/endink/Thrifty开源软件介绍:Thrifty ProjectThrifty.Net is a port of Swift(from facebook) for .Net , an attribute-based library for creating Thrift serializable types and services. you can write C# attributed object instead of IDL file and IDL generation cli. Thrifty = Thrift + Netty
Thrifty Benchmarkend to end connection without connection pool BenchmarkDotNet=v0.10.8, OS=Windows 10 Redstone 1 (10.0.14393)Processor=Intel Core i5-6300HQ CPU 2.30GHz (Skylake), ProcessorCount=4Frequency=2250001 Hz, Resolution=444.4442 ns, Timer=TSCdotnet cli version=1.0.4 [Host] : .NET Core 4.6.25211.01, 64bit RyuJIT [AttachedDebugger] DefaultJob : .NET Core 4.6.25211.01, 64bit RyuJIT
locating services use Eureka,without connection pool BenchmarkDotNet=v0.10.8, OS=Windows 10 Redstone 1 (10.0.14393)Processor=Intel Core i5-6300HQ CPU 2.30GHz (Skylake), ProcessorCount=4Frequency=2250001 Hz, Resolution=444.4442 ns, Timer=TSCdotnet cli version=1.0.4 [Host] : .NET Core 4.6.25211.01, 64bit RyuJIT [AttachedDebugger] DefaultJob : .NET Core 4.6.25211.01, 64bit RyuJIT
locating services use Eureka,with connection pool BenchmarkDotNet=v0.10.8, OS=Windows 10 Redstone 1 (10.0.14393)Processor=Intel Core i5-6300HQ CPU 2.30GHz (Skylake), ProcessorCount=4Frequency=2250001 Hz, Resolution=444.4442 ns, Timer=TSCdotnet cli version=1.0.4 [Host] : .NET Core 4.6.25211.01, 64bit RyuJIT [AttachedDebugger] DefaultJob : .NET Core 4.6.25211.01, 64bit RyuJIT
SerializationThrifty Codec convert POCO to and from Thrift.Thrifty support property、method、construction attributed. for example: [ThriftStruct] public class LogEntry { [ThriftConstructor] public LogEntry([ThriftField(1)]String category, [ThriftField(2)]String message) { this.Category = category; this.Message = message; } [ThriftField(1)] public String Category { get; } [ThriftField(2)] public String Message { get; } } ServiceThrifty Service attribute services to be exported with Thrift. For example: [ThriftService("scribe")] public interface IScribe { [ThriftMethod("getMessages")] List<LogEntry> GetMessages(); [ThriftMethod] ResultCode Log(List<LogEntry> messages); } public class Scribe : IScribe { public List<LogEntry> GetMessages() { return new List<LogEntry> { new LogEntry { Category = "c1", Message = Guid.NewGuid().ToString() }, new LogEntry { Category = "c2", Message = Guid.NewGuid().ToString() }, new LogEntry { Category = "c3", Message = Guid.NewGuid().ToString() } }; } public ResultCode Log(List<LogEntry> messages) { return ResultCode.TRY_LATER; } } Start Server var factory = new LoggerFactory(); factory.AddConsole(LogLevel.Debug); var serverConfig = new ThriftyServerOptions { QueueTimeout = TimeSpan.FromMinutes(1), TaskExpirationTimeout = TimeSpan.FromMinutes(1), ConnectionLimit = 10000 }; var bootStrap = new ThriftyBootstrap(new object[] { new Scribe() }, serverConfig, new InstanceDescription("Sample", "EurekaInstance1", "127.0.0.1"), factory); bootStrap .SslConfig(new SslConfig { CertFile = "server.pfx", CertPassword = "abc@123", CertFileProvider = new EmbeddedFileProvider(typeof(Program).GetTypeInfo().Assembly) }) .AddService(typeof(IScribe), version: "1.0.0") //true to register into eureka , disable eureka , set to false .EurekaConfig(true, new EurekaClientConfig { EurekaServerServiceUrls = "http://192.168.0.10:8761/eureka" }) // bind any .Bind(IPAddress.Any.ToString(), 3366) .StartAsync(); Use Clientvar factory = new LoggerFactory();using (var client = new ThriftyClient(new ThriftyClientOptions{ LoggerFactory = factory, ConnectionPoolEnabled = true, // default is true EurekaEnabled = true, //default is true Eureka = new ThriftyClientEurekaConfig { EurekaServerServiceUrls = "http://192.168.0.10:8761/eureka" } //optional})){ /** *************if without eureka:***************** * var service = client.Create<Thrifty.IScribe>("127.0.0.1:3366", new ClientSslConfig { CertFile = "ca.crt", FileProvider = new EmbeddedFileProvider(typeof(ClientProgram).GetTypeInfo().Assembly) }); */ var service = client.Create<Thrifty.IScribe>("1.0.0", "EurekaInstance1", new ClientSslConfig { CertFile = "ca.crt", FileProvider = new EmbeddedFileProvider(typeof(ClientProgram).GetTypeInfo().Assembly) }); var logs = service.GetMessages(); ...} Documentsdocument is here (Only Chinese documents are available now). Dependecy (our another project)
|
请发表评论