Storage.MySql - dotnet-shashlik/shashlik.eventbus GitHub Wiki

MySql

Nuget: Shashlik.EventBus.MySql

注册MySql存储

        /// <summary>
        /// 使用连接字符串初始化注册mysql存储
        /// </summary>
        /// <param name="service"></param>
        /// <param name="connectionString">连接字符串</param>
        /// <param name="publishTableName">已发布消息表名,默认eventbus_published</param>
        /// <param name="receiveTableName">已接收消息表名,默认eventbus_received</param>
        /// <returns></returns>
        public static IEventBusBuilder AddMySql(
            this IEventBusBuilder service,
            string connectionString,
            string? publishTableName = null,
            string? receiveTableName = null);

        /// <summary>
        /// 使用DbContext注册mysql存储
        /// </summary>
        /// <param name="service"></param>
        /// <param name="publishTableName">已发布消息表名,默认eventbus_published</param>
        /// <param name="receiveTableName">已接收消息表名,默认eventbus_received</param>
        /// <typeparam name="TDbContext">数据库上下文类型</typeparam>
        /// <returns></returns>
        public static IEventBusBuilder AddMySql<TDbContext>(
            this IEventBusBuilder service,
            string? publishTableName = null,
            string? receiveTableName = null)
            where TDbContext : DbContext;

        /// <summary>
        /// 使用MySql存储
        /// </summary>
        /// <param name="eventBusBuilder"></param>
        /// <param name="optionsAction"></param>
        /// <returns></returns>
        public static IEventBusBuilder AddMySql(this IEventBusBuilder eventBusBuilder, Action<EventBusMySqlOptions>? optionsAction = null);

配置项

  • PublishedTableName:已发布消息表名,默认值eventbus_published
  • ReceivedTableName:已接收消息表名,默认值eventbus_published
  • DbContextType:EF数据库上下文类型,无默认值,和ConnectionString必须配置其中一项。
  • ConnectionString:数据库连接字符串,无默认值,有DbContextType参数时,此参数无效。
⚠️ **GitHub.com Fallback** ⚠️