mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-12 02:58:31 -05:00
Modifying the migration extension to use its own service. (#21781)
* Adding migration service to sql migrations * enabling auto flush log * Adding support for env variable * Adding TDE Migration service * code cleanup * updating service downloader * Removing custom output channel * remove unnecessary await * Updated service version to get latest code * Consolidate TDE into migration service * Sync to latest main * Update sql-migration package version * Fix merge conflict error * Fixing all merge conflicts * Fixing stuff * removing extra whitespace * Cleaning up --------- Co-authored-by: Akshay Mata <akma@microsoft.com>
This commit is contained in:
46
extensions/sql-migration/src/service/provider.ts
Normal file
46
extensions/sql-migration/src/service/provider.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ApiType, MigrationExtensionService } from './features';
|
||||
import * as constants from '../constants/strings';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
export class MigrationServiceProvider {
|
||||
private services: Map<ApiType, MigrationExtensionService> = new Map();
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
public addService(service: MigrationExtensionService) {
|
||||
this.services.set(service.providerId, service);
|
||||
}
|
||||
|
||||
public async getService(serviceId: ApiType): Promise<MigrationExtensionService> {
|
||||
if (this.services.has(serviceId)) {
|
||||
return this.services.get(serviceId)!;
|
||||
}
|
||||
return this.waitUntilProviderReady(serviceId);
|
||||
}
|
||||
|
||||
public async waitUntilProviderReady(serviceId: ApiType): Promise<MigrationExtensionService> {
|
||||
const service = await vscode.window.withProgress({
|
||||
location: vscode.ProgressLocation.Notification,
|
||||
title: constants.waitingForService(serviceId),
|
||||
cancellable: false
|
||||
}, (progress, token) => {
|
||||
return new Promise<MigrationExtensionService>(resolve => {
|
||||
const interval = setInterval(() => {
|
||||
if (this.services.has(serviceId)) {
|
||||
clearInterval(interval);
|
||||
resolve(this.services.get(serviceId)!);
|
||||
}
|
||||
}, 250);
|
||||
});
|
||||
});
|
||||
return service;
|
||||
}
|
||||
}
|
||||
|
||||
export const migrationServiceProvider = new MigrationServiceProvider();
|
||||
Reference in New Issue
Block a user