Add support for clearing pooled connections (#24325)

This commit is contained in:
Cheena Malhotra
2023-09-08 09:34:42 -07:00
committed by GitHub
parent a5d3833ffb
commit 5fdac2054d
8 changed files with 73 additions and 1 deletions

View File

@@ -0,0 +1,19 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { AppContext } from '../appContext';
import * as vscode from 'vscode';
import * as constants from './constants';
import { ConnectionService } from './connectionService';
export function registerConnectionCommands(appContext: AppContext) {
appContext.extensionContext.subscriptions.push(vscode.commands.registerCommand('mssql.clearPooledConnections', async () => {
await getConnectionService(appContext).clearPooledConnections();
}));
}
function getConnectionService(appContext: AppContext): ConnectionService {
return appContext.getService<ConnectionService>(constants.ConnectionService);
}

View File

@@ -0,0 +1,33 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as constants from './constants';
import * as contracts from '../contracts';
import { BaseService, ISqlOpsFeature, SqlOpsDataClient } from 'dataprotocol-client';
import { ClientCapabilities } from 'vscode-languageclient';
import { AppContext } from '../appContext';
export class ConnectionService extends BaseService {
public static asFeature(context: AppContext): ISqlOpsFeature {
return class extends ConnectionService {
constructor(client: SqlOpsDataClient) {
super(context, client);
}
fillClientCapabilities(_: ClientCapabilities): void { }
initialize(): void { }
};
}
private constructor(context: AppContext, client: SqlOpsDataClient) {
super(client);
context.registerService(constants.ConnectionService, this);
}
async clearPooledConnections(): Promise<void> {
return this.runWithErrorHandling(contracts.ClearPooledConnectionsRequest.type, {});
}
}

View File

@@ -0,0 +1,6 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export const ConnectionService = 'ConnectionService';

View File

@@ -1733,6 +1733,11 @@ export namespace EncryptionKeysChangedNotification {
export const type = new NotificationType<DidChangeEncryptionIVKeyParams, void>('connection/encryptionKeysChanged');
}
// ------------------------------- < Clear Pooled Connections Request > ---------------------------------------
export namespace ClearPooledConnectionsRequest {
export const type = new RequestType<object, void, void, void>('connection/clearpooledconnections');
}
// ------------------------------- < Query Store > ------------------------------------
//#region Query Store

View File

@@ -27,6 +27,7 @@ import { registerTableDesignerCommands } from './tableDesigner/tableDesigner';
import { registerObjectManagementCommands } from './objectManagement/commands';
import { TelemetryActions, TelemetryReporter, TelemetryViews } from './telemetry';
import { noConvertResult, noDocumentFound, unsupportedPlatform } from './localizedConstants';
import { registerConnectionCommands } from './connection/commands';
const localize = nls.loadMessageBundle();
@@ -156,6 +157,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<IExten
registerTableDesignerCommands(appContext);
registerObjectManagementCommands(appContext);
registerConnectionCommands(appContext);
// context.subscriptions.push(new SqlNotebookController()); Temporarily disabled due to breaking query editor

View File

@@ -32,6 +32,7 @@ import { ErrorDiagnosticsProvider } from './errorDiagnostics/errorDiagnosticsPro
import { SqlProjectsService } from './sqlProjects/sqlProjectsService';
import { ObjectManagementService } from './objectManagement/objectManagementService';
import { QueryStoreService } from './queryStore/queryStoreService';
import { ConnectionService } from './connection/connectionService';
const localize = nls.loadMessageBundle();
const outputChannel = vscode.window.createOutputChannel(Constants.serviceName);
@@ -237,6 +238,7 @@ function getClientOptions(context: AppContext): ClientOptions {
AgentServicesFeature,
SerializationFeature,
SqlAssessmentServicesFeature,
ConnectionService.asFeature(context),
SchemaCompareService.asFeature(context),
LanguageExtensionService.asFeature(context),
DacFxService.asFeature(context),