一個基於 .NET Core 2.0 開發的簡單易用的快速開發框架 - LinFx

来源:https://www.cnblogs.com/LinFx/archive/2018/12/12/10106540.html
-Advertisement-
Play Games

LinFx 一個基於 .NET Core 2.0 開發的簡單易用的快速開發框架,遵循領域驅動設計(DDD)規範約束,提供實現事件驅動、事件回溯、響應式等特性的基礎設施。讓開發者享受到正真意義的面向對象設計模式來帶的美感。 LinFx.Extensions Caching、DapperExtensio ...


LinFx

GitHub license

一個基於 .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


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 未壓縮前 ...
  • 上半節已經下載好了Zookeeper,以及新建了兩個應用provider和consumer,這一節我們就結合dubbo來測試一下分散式可不可以用。 現在就來簡單用一下,註意:這裡只是涉及最簡單的部分,新手入門用的,詳細的內容要學習的可以自己查一查資料;然後再說說用Zookeeper當作註冊中心的一個 ...
  • 第一個程式 print “Hello World!” print“Hello Again” print “I like type” print "This is fun." ...
  • 一、RBAC分析 基於角色的許可權訪問控制(Role-Based Access Control),這裡存在這麼幾個玩意兒:角色、許可權,用戶 表:roles、permissions、role_has_permissions、model_has_roles、model_has_permissions(最後 ...
  • 一、什麼是序列化組件? 本質上為了實現前後端分離,而進行json序列化的一個組件形式,極大方便瞭解析數據的作用 所有序列化是基於APIView解析器實現的,通過內部的多繼承關係方便實現進行數據序列化的實現 二、使用方法 第一步:創建序列化類 創建出返回頁面顯示的欄位,一對多關係同創建普通欄位一樣,無 ...
  • 題目鏈接 思路 觀察這個$(r - l + 1)/2$,很容易證明,如果一個數出現次數大於$(r - l + 1) / 2$,那麼這個區間內第$(r - l + 1) / 2 + 1$ ...
  • 學習了一下https://github.com/TyCoding/ssm-redis-solr這個github上的solr搜索功能,現在來記錄一下。 我的理解就是solr有點類似於資料庫,但它是有索引的資料庫,按很多欄位建立索引,可能是b+樹或者散列索引,然後就能夠實現海量數據的查找。solr通過導 ...
  • 如下麵的例子: 在腳本中引入from future import division 將除數或者被除數轉換為浮點數 如下麵的例子: ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...