zoukankan      html  css  js  c++  java
  • 思考一种好的架构(十二)

    事件溯源(TracingSource)

     /// <summary>
        /// 数据库事件溯源实体
        /// </summary>
        [Table(name: "TracingSource")]
       public class TracingSourceEntity
        {
            [ColumnAttribute(IsPrimaryKey =true)]
            [AutoIncrement]
            public int ID { get; set; }
            /// <summary>
            /// 执行时间
            /// </summary>
            public DateTime ExecuteTimer { get; set; }
    
            /// <summary>
            /// 执行Sql
            /// </summary>
            public string ExecuteSql { get; set; }
        }
      class DCCQRSCommandEventHandler : INotificationHandler<DCCQRSCommandEvent>
        {
            IDbContext DC;
            IMapper Mapper;
            public DCCQRSCommandEventHandler(IDbContext DC,IMapper Mapper) {
                this.DC = DC;
                this.Mapper = Mapper;
            }
    
            public Task Handle(DCCQRSCommandEvent notification, CancellationToken cancellationToken)
            {
                DC.Insert(Mapper.Map<TracingSourceEntity>(notification));
                return Task.CompletedTask;
            }
        }
    class StartExecute : BaseStartExecute
        {
            public override void Execute()
            {
                EventBusPost.CreateEvent(typeof(Startup));
                MapperPost.CreateMap(x =>
                    x.CreateMap<DCCQRSCommandEvent, TracingSourceEntity>().ForMember(dest => dest.ID, opt => opt.Ignore())
                );
            }
        }
    
        public static class Startup
        {
            public static void ConfigureServices(IServiceCollection services)
            {
              
            }
    
            public static void Configure(IApplicationBuilder app, IHostingEnvironment env)
            {
             
            }
        }

    事件溯源服务的问题

      1、没有数据回溯功能,充其量也只是一个事件持久化

      2、使用业务库,而不是NoSql

    解释

      1、懒

      2、虽然它使用了业务库,但是还是一个归类为普通服务,使用业务库做持久化只是暂时的

  • 相关阅读:
    循环神经网络(LSTM和GRU)(1)
    threading包的例子和queue包的例子
    xgboost调参
    理解 Python 中的 *args 和 **kwargs
    TFRecords文件的生成和读取(1)
    tensorflow函数介绍(4)
    python其他篇(1)
    python实现Restful服务(基于flask)(2)
    开源多线程性能测试工具-sysbench
    MySQL 8.0.0 版本发布,亮点都在这了!
  • 原文地址:https://www.cnblogs.com/AnAng/p/12612389.html
Copyright © 2011-2022 走看看