mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from master
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { localize } from 'vs/nls';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IChannel, getDelayedChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc';
|
||||
import { Client } from 'vs/base/parts/ipc/node/ipc.net';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { connectRemoteAgentManagement, RemoteAgentConnectionContext } from 'vs/platform/remote/node/remoteAgentConnection';
|
||||
import { IWindowConfiguration } from 'vs/platform/windows/common/windows';
|
||||
import { RemoteExtensionEnvironmentChannelClient } from 'vs/workbench/services/remote/node/remoteAgentEnvironmentChannel';
|
||||
import { IRemoteAgentConnection, IRemoteAgentEnvironment, IRemoteAgentService } from 'vs/workbench/services/remote/node/remoteAgentService';
|
||||
import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver';
|
||||
|
||||
export class RemoteAgentService implements IRemoteAgentService {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
private readonly _connection: IRemoteAgentConnection | null = null;
|
||||
|
||||
constructor(
|
||||
window: IWindowConfiguration,
|
||||
@INotificationService notificationService: INotificationService,
|
||||
@IEnvironmentService environmentService: IEnvironmentService,
|
||||
@IRemoteAuthorityResolverService remoteAuthorityResolverService: IRemoteAuthorityResolverService
|
||||
) {
|
||||
if (window.remoteAuthority) {
|
||||
this._connection = new RemoteAgentConnection(window.remoteAuthority, notificationService, environmentService, remoteAuthorityResolverService);
|
||||
}
|
||||
}
|
||||
|
||||
getConnection(): IRemoteAgentConnection | null {
|
||||
return this._connection;
|
||||
}
|
||||
}
|
||||
|
||||
class RemoteAgentConnection extends Disposable implements IRemoteAgentConnection {
|
||||
|
||||
readonly remoteAuthority: string;
|
||||
private _connection: Thenable<Client<RemoteAgentConnectionContext>> | null;
|
||||
private _environment: Thenable<IRemoteAgentEnvironment | null> | null;
|
||||
|
||||
constructor(
|
||||
remoteAuthority: string,
|
||||
private _notificationService: INotificationService,
|
||||
private _environmentService: IEnvironmentService,
|
||||
private _remoteAuthorityResolverService: IRemoteAuthorityResolverService
|
||||
) {
|
||||
super();
|
||||
this.remoteAuthority = remoteAuthority;
|
||||
this._connection = null;
|
||||
this._environment = null;
|
||||
}
|
||||
|
||||
getEnvironment(): Thenable<IRemoteAgentEnvironment | null> {
|
||||
if (!this._environment) {
|
||||
const client = new RemoteExtensionEnvironmentChannelClient(this.getChannel('remoteextensionsenvironment'));
|
||||
|
||||
// Let's cover the case where connecting to fetch the remote extension info fails
|
||||
this._environment = client.getEnvironmentData(this.remoteAuthority, this._environmentService.extensionDevelopmentLocationURI)
|
||||
.then(undefined, err => { this._notificationService.error(localize('connectionError', "Failed to connect to the remote extension host agent (Error: {0})", err ? err.message : '')); return null; });
|
||||
}
|
||||
return this._environment;
|
||||
}
|
||||
|
||||
getChannel<T extends IChannel>(channelName: string): T {
|
||||
return <T>getDelayedChannel(this._getOrCreateConnection().then(c => c.getChannel(channelName)));
|
||||
}
|
||||
|
||||
registerChannel<T extends IServerChannel<RemoteAgentConnectionContext>>(channelName: string, channel: T): void {
|
||||
this._getOrCreateConnection().then(client => client.registerChannel(channelName, channel));
|
||||
}
|
||||
|
||||
private _getOrCreateConnection(): Thenable<Client<RemoteAgentConnectionContext>> {
|
||||
if (!this._connection) {
|
||||
this._connection = this._remoteAuthorityResolverService.resolveAuthority(this.remoteAuthority).then((resolvedAuthority) => {
|
||||
return connectRemoteAgentManagement(this.remoteAuthority, resolvedAuthority.host, resolvedAuthority.port, `renderer`);
|
||||
});
|
||||
}
|
||||
return this._connection;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { OperatingSystem } from 'vs/base/common/platform';
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import { IChannel } from 'vs/base/parts/ipc/node/ipc';
|
||||
import { IExtensionDescription } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { IRemoteAgentEnvironment } from 'vs/workbench/services/remote/node/remoteAgentService';
|
||||
|
||||
export interface IRemoteAgentEnvironmentDTO {
|
||||
pid: number;
|
||||
appRoot: UriComponents;
|
||||
appSettingsHome: UriComponents;
|
||||
logsPath: UriComponents;
|
||||
extensionsPath: UriComponents;
|
||||
extensionHostLogsPath: UriComponents;
|
||||
globalStorageHome: UriComponents;
|
||||
extensions: IExtensionDescription[];
|
||||
os: OperatingSystem;
|
||||
}
|
||||
|
||||
export class RemoteExtensionEnvironmentChannelClient {
|
||||
|
||||
constructor(private channel: IChannel) { }
|
||||
|
||||
getEnvironmentData(remoteAuthority: string, extensionDevelopmentPath?: URI): Thenable<IRemoteAgentEnvironment> {
|
||||
return this.channel.call<IRemoteAgentEnvironmentDTO>('getEnvironmentData', [remoteAuthority, extensionDevelopmentPath])
|
||||
.then((data: IRemoteAgentEnvironmentDTO): IRemoteAgentEnvironment => {
|
||||
return {
|
||||
pid: data.pid,
|
||||
appRoot: URI.revive(data.appRoot),
|
||||
appSettingsHome: URI.revive(data.appSettingsHome),
|
||||
logsPath: URI.revive(data.logsPath),
|
||||
extensionsPath: URI.revive(data.extensionsPath),
|
||||
extensionHostLogsPath: URI.revive(data.extensionHostLogsPath),
|
||||
globalStorageHome: URI.revive(data.globalStorageHome),
|
||||
extensions: data.extensions.map(ext => { (<any>ext).extensionLocation = URI.revive(ext.extensionLocation); return ext; }),
|
||||
os: data.os
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
42
src/vs/workbench/services/remote/node/remoteAgentService.ts
Normal file
42
src/vs/workbench/services/remote/node/remoteAgentService.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { OperatingSystem } from 'vs/base/common/platform';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IExtensionDescription } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { RemoteAgentConnectionContext } from 'vs/platform/remote/node/remoteAgentConnection';
|
||||
|
||||
export const RemoteExtensionLogFileName = 'remoteagent';
|
||||
|
||||
export const IRemoteAgentService = createDecorator<IRemoteAgentService>('remoteAgentService');
|
||||
|
||||
export interface IRemoteAgentEnvironment {
|
||||
pid: number;
|
||||
appRoot: URI;
|
||||
appSettingsHome: URI;
|
||||
logsPath: URI;
|
||||
extensionsPath: URI;
|
||||
extensionHostLogsPath: URI;
|
||||
globalStorageHome: URI;
|
||||
extensions: IExtensionDescription[];
|
||||
os: OperatingSystem;
|
||||
}
|
||||
|
||||
export interface IRemoteAgentService {
|
||||
_serviceBrand: any;
|
||||
|
||||
getConnection(): IRemoteAgentConnection | null;
|
||||
}
|
||||
|
||||
export interface IRemoteAgentConnection {
|
||||
readonly remoteAuthority: string;
|
||||
|
||||
getEnvironment(): Thenable<IRemoteAgentEnvironment | null>;
|
||||
|
||||
getChannel<T extends IChannel>(channelName: string): T;
|
||||
registerChannel<T extends IServerChannel<RemoteAgentConnectionContext>>(channelName: string, channel: T);
|
||||
}
|
||||
Reference in New Issue
Block a user