public async Task <SmartSqlMapConfig> LoadAsync() { _logger.LogDebug($"SmartSql.ZooKeeperConfigLoader Load: {options.SqlMapConfigPath} Starting"); var configResult = await ZooClient.getDataAsync(options.SqlMapConfigPath, new SmartSqlMapConfigWatcher(_loggerFactory, this)); var configStream = new ConfigStream { Path = options.SqlMapConfigPath, Stream = new MemoryStream(configResult.Data) }; var config = LoadConfig(configStream); foreach (var sqlmapSource in config.SmartSqlMapSources) { switch (sqlmapSource.Type) { case SmartSqlMapSource.ResourceType.File: { var sqlmap = await LoadSmartSqlMapAsync(sqlmapSource.Path, config); config.SmartSqlMaps.Add(sqlmap); break; } case SmartSqlMapSource.ResourceType.Directory: { var sqlmapChildren = await ZooClient.getChildrenAsync(sqlmapSource.Path); foreach (var sqlmapChild in sqlmapChildren.Children) { var sqlmapPath = $"{sqlmapSource.Path}/{sqlmapChild}"; var sqlmap = await LoadSmartSqlMapAsync(sqlmapPath, config); config.SmartSqlMaps.Add(sqlmap); } break; } default: { throw new ArgumentException("unknow SmartSqlMap.Type!"); } } } _logger.LogDebug($"SmartSql.ZooKeeperConfigLoader Load: {options.SqlMapConfigPath} End"); return(config); }