LinFx

一个基于 .NET Core 2.0 开发的简单易用的快速开发框架,遵循领域驱动设计(DDD)规范约束,提供实现事件驱动、事件回溯、响应式等特性的基础设施。让开发者享受到正真意义的面向对象设计模式来带的美感。

LinFx.Extensions

Caching、DapperExtensions、Elasticsearch、EventBus、Metrics、Mongo、RabbitMQ

特性

  1. 领域驱动设计(DDD)
  2. 事件驱动架构 (EDA)
  3. 事件回溯 (ES)
  4. 最终一致性 (Eventually Consistent)
  5. 框架中每个组件都有基础实现,最简单时只需一个核心类库就能跑起来
  6. 遵循端口与适配器模式,框架组件适配多种第三方组件实现,可从单体架构到面向服务架构按需扩展

设计规范

  1. 尽量使用.NET Standard和官方提供的类库,第三方类库设计成组件利用DI来按需组合。

安装Nuget包

PM> Install-Package LinFx

开发环境

  1. Visual Studio 15.3+
  2. .NET Core SDK 2.2+

Samples

public void ConfigureServices(IServiceCollection services)
{
services.AddLinFx()
.AddDistributedRedisCache(options =>
{
options.Configuration = configuration.GetConnectionString("ReidsConnection");
})
.AddMongoDBContext(options =>
{
options.Name = "default";
options.Configuration = configuration.GetConnectionString("MongoConnection");
})
.AddElasticsearch(options =>
{
options.DefaultIndex = "default";
options.Host = "http://10.0.1.112:9200";
});
}

EventBus

using LinFx.Extensions.EventBus.Abstractions;
using LinFx.Test.Extensions.EventBus.Events;
using LinFx.Utils;
using LinFx.Extensions.EventBus.RabbitMQ;
using Microsoft.Extensions.DependencyInjection;
using System.Threading.Tasks;
using Xunit;
using LinFx.Test.Extensions.EventBus.EventHandling;
using System.Collections.Generic;
using System; namespace LinFx.Test.Extensions.EventBus
{
public class EventBusRabbitMQTest
{
private readonly IEventBus _eventBus; public EventBusRabbitMQTest()
{
var services = new ServiceCollection(); services.AddLinFx()
.AddEventBus(options =>
{
options.Durable = true;
options.BrokerName = "tc_cloud_event_bus";
options.QueueName = "tc_cloud_process_queue";
options.ConfigureEventBus = (fx, builder) => builder.UseRabbitMQ(fx, x =>
{
x.Host = "14.21.34.85";
x.UserName = "admin";
x.Password = "admin.123456";
});
}); //services
services.AddTransient<OrderStatusChangedToAwaitingValidationIntegrationEventHandler>();
//services.AddTransient<OrderStatusChangedToPaidIntegrationEventHandler>(); var applicationServices = services.BuildServiceProvider(); //ConfigureEventBus
_eventBus = applicationServices.GetRequiredService<IEventBus>();
_eventBus.Subscribe<OrderStatusChangedToAwaitingValidationIntegrationEvent, OrderStatusChangedToAwaitingValidationIntegrationEventHandler>();
//eventBus.Subscribe<OrderStatusChangedToPaidIntegrationEvent, OrderStatusChangedToPaidIntegrationEventHandler>();
} [Fact]
public async Task Should_Call_Handler_On_Event_With_Correct_SourceAsync()
{
var orderId = Guid.NewGuid().GetHashCode() & ushort.MaxValue;
var evt = new OrderStatusChangedToAwaitingValidationIntegrationEvent(orderId, new List<OrderStockItem>
{
});
await _eventBus.PublishAsync(evt); //for (int i = 0; i < 2; i++)
//{
// await _eventBus.PublishAsync(new ClientCreateIntergrationEvent
// {
// ClientId = IDUtils.CreateNewId().ToString(),
// ClientSecrets = new[] { "191d437f0cc3463b85669f2b570cdc21" },
// AllowedGrantTypes = new[] { "client_credentials" },
// AllowedScopes = new[] { "api3.device" }
// });
//}
}
}
}

送上 github

https://github.com/linfx/LinFx

最新文章

  1. ios 按钮点击无反应
  2. POJ 2457 Part Acquisition
  3. linux下vi命令大全[转]
  4. 使用python递归子目录处理日志文件
  5. NSThread
  6. SOAPUI请求及mockservice 使用
  7. jQuery.merge( first, second )返回: Array
  8. JQuery中实现Ajax
  9. Android - 读取XML文件中的数据
  10. @NotEmpty、@NotBlank、@NotNull的区别
  11. U-Boot内存管理
  12. Java反射机制小结和实际操作
  13. Python文件打包成exe
  14. Array 转 Set
  15. __str__ 和 __repr
  16. 百度地图经纬度和地址互转(Java代码)
  17. linux源配置
  18. 20155237 2016-2017-2 《Java程序设计》第9周学习总结
  19. netsh常用命令
  20. [转载+原创]Emgu CV on C# (五) —— Emgu CV on 局部自适应阈值二值化

热门文章

  1. 转:oracle几组重要的常见视图-v$segstat,v$segment_statistics,v$filestat,v$rollstat
  2. SQL2008R转SQL2005
  3. 使用Easy-creds创建伪AP
  4. Java ThreadPoolExecutor线程池原理及源码分析
  5. http协议请求响应内容示例
  6. Keepalived使用小结
  7. Java面向对象-访问控制权限
  8. 开启mysql远程访问
  9. Java多线程-新特征-原子量
  10. oracle xe远程访问