예제 #1
0
        public IKustoManagementGateway CreateGateway(Uri clusterUri, string database)
        {
            ICslAdminProvider?commandProvider;

            //  Make the command provider singleton as they hold HTTP connections
            if (!_providerCache.TryGetValue(clusterUri, out commandProvider))
            {
                lock (_providerCache)
                {   //  Double-check within lock
                    if (!_providerCache.TryGetValue(clusterUri, out commandProvider))
                    {
                        var kustoConnectionStringBuilder = CreateKustoConnectionStringBuilder(
                            clusterUri,
                            _tokenProvider);

                        commandProvider =
                            KustoClientFactory.CreateCslCmAdminProvider(kustoConnectionStringBuilder);

                        _providerCache.Add(clusterUri, commandProvider);
                    }
                }
            }

            return(new KustoManagementGateway(
                       clusterUri,
                       database,
                       commandProvider,
                       _tracer));
        }