Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use separate urls for querying and downloading of LS #3078

Merged
merged 3 commits into from
Oct 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { inject, injectable } from 'inversify';
import { AzureBlobStoreNugetRepository } from '../../common/nuget/azureBlobStoreNugetRepository';
import { IServiceContainer } from '../../ioc/types';

const azureBlobStorageAccount = 'https://pvsc.azureedge.net';
const azureBlobStorageAccount = 'https://pvsc.blob.core.windows.net';
const azureCDNBlobStorageAccount = 'https://pvsc.azureedge.net';

export enum LanguageServerDownloadChannel {
stable = 'stable',
Expand All @@ -24,20 +25,20 @@ export enum LanguageServerPackageStorageContainers {
@injectable()
export class StableLanguageServerPackageRepository extends AzureBlobStoreNugetRepository {
constructor(@inject(IServiceContainer) serviceContainer: IServiceContainer) {
super(serviceContainer, azureBlobStorageAccount, LanguageServerPackageStorageContainers.stable);
super(serviceContainer, azureBlobStorageAccount, LanguageServerPackageStorageContainers.stable, azureCDNBlobStorageAccount);
}
}

@injectable()
export class BetaLanguageServerPackageRepository extends AzureBlobStoreNugetRepository {
constructor(@inject(IServiceContainer) serviceContainer: IServiceContainer) {
super(serviceContainer, azureBlobStorageAccount, LanguageServerPackageStorageContainers.beta);
super(serviceContainer, azureBlobStorageAccount, LanguageServerPackageStorageContainers.beta, azureCDNBlobStorageAccount);
}
}

@injectable()
export class DailyLanguageServerPackageRepository extends AzureBlobStoreNugetRepository {
constructor(@inject(IServiceContainer) serviceContainer: IServiceContainer) {
super(serviceContainer, azureBlobStorageAccount, LanguageServerPackageStorageContainers.daily);
super(serviceContainer, azureBlobStorageAccount, LanguageServerPackageStorageContainers.daily, azureCDNBlobStorageAccount);
}
}
9 changes: 5 additions & 4 deletions src/client/common/nuget/azureBlobStoreNugetRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ import { INugetRepository, INugetService, NugetPackage } from './types';
export class AzureBlobStoreNugetRepository implements INugetRepository {
constructor(@inject(IServiceContainer) private readonly serviceContainer: IServiceContainer,
@unmanaged() protected readonly azureBlobStorageAccount: string,
@unmanaged() protected readonly azureBlobStorageContainer: string) { }
@unmanaged() protected readonly azureBlobStorageContainer: string,
@unmanaged() protected readonly azureCDNBlobStorageAccount: string) { }
public async getPackages(packageName: string): Promise<NugetPackage[]> {
return this.listPackages(this.azureBlobStorageAccount, this.azureBlobStorageContainer, packageName);
return this.listPackages(this.azureBlobStorageAccount, this.azureBlobStorageContainer, packageName, this.azureCDNBlobStorageAccount);
}

@captureTelemetry(PYTHON_LANGUAGE_SERVER_LIST_BLOB_STORE_PACKAGES)
@traceVerbose('Listing Nuget Packages')
public listPackages(azureBlobStorageAccount: string, azureBlobStorageContainer: string, packageName: string) {
protected listPackages(azureBlobStorageAccount: string, azureBlobStorageContainer: string, packageName: string, azureCDNBlobStorageAccount: string) {
// tslint:disable-next-line:no-require-imports
const az = require('azure-storage') as typeof azStorageTypes;
const blobStore = az.createBlobServiceAnonymous(azureBlobStorageAccount);
Expand All @@ -39,7 +40,7 @@ export class AzureBlobStoreNugetRepository implements INugetRepository {
resolve(result.entries.map(item => {
return {
package: item.name,
uri: `${azureBlobStorageAccount}/${azureBlobStorageContainer}/${item.name}`,
uri: `${azureCDNBlobStorageAccount}/${azureBlobStorageContainer}/${item.name}`,
version: nugetService.getVersionFromPackageFileName(item.name)
};
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ suite('Language Server Download Channels', () => {
}
const instance = new class extends classToCreate {
constructor() { super(serviceContainer.object); }
public get storageAccount() { return this.azureBlobStorageAccount; }
public get storageAccount() { return this.azureCDNBlobStorageAccount; }
public get storageContainer() { return this.azureBlobStorageContainer; }
}();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import { PlatformService } from '../../../client/common/platform/platformService
import { IPlatformService } from '../../../client/common/platform/types';
import { IServiceContainer } from '../../../client/ioc/types';

const azureBlobStorageAccount = 'https://pvsc.blob.core.windows.net';
const azureCDNBlobStorageAccount = 'https://pvsc.azureedge.net';

suite('Language Server Package Service', () => {
let serviceContainer: typeMoq.IMock<IServiceContainer>;
setup(() => {
Expand Down Expand Up @@ -76,7 +79,7 @@ suite('Language Server Package Service', () => {
const platformService = new PlatformService();
serviceContainer.setup(c => c.get(typeMoq.It.isValue(IPlatformService))).returns(() => platformService);
const defaultStorageChannel = LanguageServerPackageStorageContainers.stable;
const nugetRepo = new AzureBlobStoreNugetRepository(serviceContainer.object, 'https://pvsc.azureedge.net', defaultStorageChannel);
const nugetRepo = new AzureBlobStoreNugetRepository(serviceContainer.object, azureBlobStorageAccount, defaultStorageChannel, azureCDNBlobStorageAccount);
serviceContainer.setup(c => c.get(typeMoq.It.isValue(INugetRepository))).returns(() => nugetRepo);
const lsPackageService = new LanguageServerPackageService(serviceContainer.object);
const packageName = lsPackageService.getNugetPackageName();
Expand Down
5 changes: 4 additions & 1 deletion src/test/common/nuget/azureBobStoreRepository.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import { PlatformService } from '../../../client/common/platform/platformService
import { IPlatformService } from '../../../client/common/platform/types';
import { IServiceContainer } from '../../../client/ioc/types';

const azureBlobStorageAccount = 'https://pvsc.blob.core.windows.net';
const azureCDNBlobStorageAccount = 'https://pvsc.azureedge.net';

suite('Nuget Azure Storage Repository', () => {
let serviceContainer: typeMoq.IMock<IServiceContainer>;
let httpClient: typeMoq.IMock<IHttpClient>;
Expand All @@ -29,7 +32,7 @@ suite('Nuget Azure Storage Repository', () => {
serviceContainer.setup(c => c.get(typeMoq.It.isValue(INugetService))).returns(() => nugetService.object);
const defaultStorageChannel = LanguageServerPackageStorageContainers.stable;

repo = new AzureBlobStoreNugetRepository(serviceContainer.object, 'https://pvsc.azureedge.net', defaultStorageChannel);
repo = new AzureBlobStoreNugetRepository(serviceContainer.object, azureBlobStorageAccount, defaultStorageChannel, azureCDNBlobStorageAccount);
});

test('Get all packages', async function () {
Expand Down