/// <summary> /// Discovers schemas located in the users DB2 database /// </summary> /// <param name="request"></param> /// <param name="context"></param> /// <returns>Discovered schemas</returns> public override async Task <DiscoverSchemasResponse> DiscoverSchemas(DiscoverSchemasRequest request, ServerCallContext context) { Logger.SetLogPrefix("discover"); Logger.Info("Discovering Schemas..."); var sampleSize = checked ((int)request.SampleSize); DiscoverSchemasResponse discoverSchemasResponse = new DiscoverSchemasResponse(); // only return requested schemas if refresh mode selected if (request.Mode == DiscoverSchemasRequest.Types.Mode.All) { if (_server.Settings.DisableDiscovery) { Logger.Info("Discovery is disabled. Skipping."); return(new DiscoverSchemasResponse()); } // get all schemas try { var schemas = Discover.GetAllSchemas(_connectionFactory, _server.Settings, sampleSize); discoverSchemasResponse.Schemas.AddRange(await schemas.ToListAsync()); Logger.Info($"Schemas returned: {discoverSchemasResponse.Schemas.Count}"); return(discoverSchemasResponse); } catch (Exception e) { Logger.Error(e, e.Message, context); return(new DiscoverSchemasResponse()); } } try { var refreshSchemas = request.ToRefresh; Logger.Info($"Refresh schemas attempted: {refreshSchemas.Count}"); var schemas = Discover.GetRefreshSchemas(_connectionFactory, refreshSchemas, sampleSize); discoverSchemasResponse.Schemas.AddRange(await schemas.ToListAsync()); // return all schemas Logger.Info($"Schemas returned: {discoverSchemasResponse.Schemas.Count}"); return(discoverSchemasResponse); } catch (Exception e) { Logger.Error(e, e.Message, context); return(new DiscoverSchemasResponse()); } }