Skip to content

Commit

Permalink
[bridge] Fix PreparingUpdateEmulator initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
geropl authored and roboquat committed Feb 17, 2022
1 parent 5f6114c commit 8c6d938
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
9 changes: 6 additions & 3 deletions components/ws-manager-bridge/src/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* See License-AGPL.txt in the project root for license information.
*/

import { inject, injectable } from "inversify";
import { inject, injectable, interfaces } from "inversify";
import { MessageBusIntegration } from "./messagebus-integration";
import { Disposable, WorkspaceInstance, Queue, WorkspaceInstancePort, PortVisibility, RunningWorkspaceInfo, DisposableCollection } from "@gitpod/gitpod-protocol";
import { WorkspaceStatus, WorkspacePhase, GetWorkspacesRequest, WorkspaceConditionBool, PortVisibility as WsManPortVisibility, WorkspaceType, PromisifiedWorkspaceManagerClient } from "@gitpod/ws-manager/lib";
Expand All @@ -20,7 +20,7 @@ import { Timestamp } from "google-protobuf/google/protobuf/timestamp_pb";
import { Configuration } from "./config";
import { WorkspaceCluster } from "@gitpod/gitpod-protocol/lib/workspace-cluster";
import { repeat } from "@gitpod/gitpod-protocol/lib/util/repeat";
import { PreparingUpdateEmulator } from "./preparing-update-emulator";
import { PreparingUpdateEmulator, PreparingUpdateEmulatorFactory } from "./preparing-update-emulator";

export const WorkspaceManagerBridgeFactory = Symbol("WorkspaceManagerBridgeFactory");

Expand Down Expand Up @@ -51,6 +51,9 @@ export class WorkspaceManagerBridge implements Disposable {
@inject(Configuration)
protected readonly config: Configuration;

@inject(PreparingUpdateEmulatorFactory)
protected readonly preparingUpdateEmulatorFactory: interfaces.Factory<PreparingUpdateEmulator>;

@inject(IAnalyticsWriter)
protected readonly analytics: IAnalyticsWriter;

Expand Down Expand Up @@ -88,7 +91,7 @@ export class WorkspaceManagerBridge implements Disposable {
startStatusUpdateHandler(false);

// emulate WorkspaceInstance updates for all Workspaces in the "preparing" phase in this cluster
const updateEmulator = new PreparingUpdateEmulator();
const updateEmulator = this.preparingUpdateEmulatorFactory() as PreparingUpdateEmulator;
this.disposables.push(updateEmulator);
updateEmulator.start(cluster.name);
}
Expand Down
4 changes: 2 additions & 2 deletions components/ws-manager-bridge/src/container-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { newAnalyticsWriterFromEnv } from '@gitpod/gitpod-protocol/lib/util/anal
import { MetaInstanceController } from './meta-instance-controller';
import { IClientCallMetrics } from '@gitpod/content-service/lib/client-call-metrics';
import { PrometheusClientCallMetrics } from "@gitpod/gitpod-protocol/lib/messaging/client-call-metrics";
import { PreparingUpdateEmulator } from './preparing-update-emulator';
import { PreparingUpdateEmulator, PreparingUpdateEmulatorFactory } from './preparing-update-emulator';

export const containerModule = new ContainerModule(bind => {

Expand Down Expand Up @@ -70,5 +70,5 @@ export const containerModule = new ContainerModule(bind => {

bind(IAnalyticsWriter).toDynamicValue(newAnalyticsWriterFromEnv).inSingletonScope();

bind(PreparingUpdateEmulator).toSelf().inSingletonScope();
bind(PreparingUpdateEmulatorFactory).toAutoFactory(PreparingUpdateEmulator);
});
2 changes: 2 additions & 0 deletions components/ws-manager-bridge/src/preparing-update-emulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { MessageBusIntegration } from "./messagebus-integration";
import { GarbageCollectedCache } from "@gitpod/gitpod-protocol/lib/util/garbage-collected-cache";
import * as crypto from 'crypto';

export const PreparingUpdateEmulatorFactory = Symbol("PreparingUpdateEmulatorFactory");

interface CacheEntry {
instance: WorkspaceInstance,
userId: string,
Expand Down

0 comments on commit 8c6d938

Please sign in to comment.