@eclipse-che/devworkspace-client
Advanced tools
Comparing version 0.0.1-1614204387 to 0.0.1-1614264002
@@ -6,2 +6,4 @@ import { AxiosInstance } from 'axios'; | ||
private axios; | ||
private projectInitRequestTimeoutMs; | ||
private projectRequestDelay; | ||
constructor(axios: AxiosInstance); | ||
@@ -16,2 +18,3 @@ listInNamespace(namespace: string): Promise<IDevWorkspace[]>; | ||
private createProject; | ||
private waitForProjectToBeReady; | ||
} |
@@ -497,2 +497,4 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
function RestDevWorkspaceApi(axios) { | ||
this.projectInitRequestTimeoutMs = 10000; | ||
this.projectRequestDelay = 100; | ||
this.axios = axios; | ||
@@ -627,11 +629,13 @@ } | ||
isOpenShift = _a.sent(); | ||
if (!isOpenShift) return [3 /*break*/, 3]; | ||
if (!isOpenShift) return [3 /*break*/, 4]; | ||
return [4 /*yield*/, this.doesProjectExist(namespace)]; | ||
case 2: | ||
doesProjectAlreadyExist = _a.sent(); | ||
if (!doesProjectAlreadyExist) { | ||
this.createProject(namespace); | ||
} | ||
_a.label = 3; | ||
case 3: return [2 /*return*/]; | ||
if (!!doesProjectAlreadyExist) return [3 /*break*/, 4]; | ||
this.createProject(namespace); | ||
return [4 /*yield*/, this.waitForProjectToBeReady(namespace)]; | ||
case 3: | ||
_a.sent(); | ||
_a.label = 4; | ||
case 4: return [2 /*return*/]; | ||
} | ||
@@ -669,2 +673,32 @@ }); | ||
}; | ||
RestDevWorkspaceApi.prototype.waitForProjectToBeReady = function (namespace) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var secondsAttempted, request; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
secondsAttempted = 0; | ||
return [4 /*yield*/, this.doesProjectExist(namespace)]; | ||
case 1: | ||
request = _a.sent(); | ||
_a.label = 2; | ||
case 2: | ||
if (!(secondsAttempted < this.projectInitRequestTimeoutMs && !request)) return [3 /*break*/, 5]; | ||
return [4 /*yield*/, this.doesProjectExist(namespace)]; | ||
case 3: | ||
request = _a.sent(); | ||
return [4 /*yield*/, helper_1.delay(this.projectRequestDelay)]; | ||
case 4: | ||
_a.sent(); | ||
secondsAttempted += this.projectRequestDelay; | ||
return [3 /*break*/, 2]; | ||
case 5: | ||
if (secondsAttempted === this.projectInitRequestTimeoutMs) { | ||
throw new Error("Project " + namespace + " could not be initialized in " + this.projectInitRequestTimeoutMs / 1000 + " seconds"); | ||
} | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
return RestDevWorkspaceApi; | ||
@@ -671,0 +705,0 @@ }()); |
{ | ||
"name": "@eclipse-che/devworkspace-client", | ||
"version": "0.0.1-1614204387", | ||
"version": "0.0.1-1614264002", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/server.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
22360653
2320