@chevre/domain 21.2.0-alpha.21 → 21.2.0-alpha.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -18,7 +18,7 @@ export type TaskOperation<T> = (repos: {
|
|
|
18
18
|
export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
19
19
|
export declare function executeById(params: {
|
|
20
20
|
id: string;
|
|
21
|
-
executor
|
|
21
|
+
executor?: {
|
|
22
22
|
name: string;
|
|
23
23
|
};
|
|
24
24
|
}): IOperation<void>;
|
|
@@ -27,7 +27,7 @@ export declare function executeById(params: {
|
|
|
27
27
|
*/
|
|
28
28
|
export declare function executeByName<T extends factory.taskName>(params: {
|
|
29
29
|
name: T;
|
|
30
|
-
executor
|
|
30
|
+
executor?: {
|
|
31
31
|
name: string;
|
|
32
32
|
};
|
|
33
33
|
}): IOperation<void>;
|
|
@@ -20,14 +20,21 @@ const NotificationService = require("./notification");
|
|
|
20
20
|
const factory_1 = require("./notification/factory");
|
|
21
21
|
const settings_1 = require("../settings");
|
|
22
22
|
const debug = createDebug('chevre-domain:service:task');
|
|
23
|
+
const DEFAULT_EXECUTOR_NAME = `${process.env.GAE_APPLICATION}:${process.env.GAE_INSTANCE}:${process.env.GAE_SERVICE}:jobs`;
|
|
23
24
|
function executeById(params) {
|
|
24
25
|
return (settings) => __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
var _a;
|
|
25
27
|
const taskRepo = new task_1.MongoRepository(settings.connection);
|
|
26
28
|
// 未実行のタスクを取得
|
|
27
29
|
// tslint:disable-next-line:no-null-keyword
|
|
28
30
|
let task = null;
|
|
29
31
|
try {
|
|
30
|
-
task = yield taskRepo.executeById({
|
|
32
|
+
task = yield taskRepo.executeById({
|
|
33
|
+
id: params.id,
|
|
34
|
+
executor: {
|
|
35
|
+
name: (typeof ((_a = params.executor) === null || _a === void 0 ? void 0 : _a.name) === 'string') ? params.executor.name : DEFAULT_EXECUTOR_NAME
|
|
36
|
+
}
|
|
37
|
+
});
|
|
31
38
|
}
|
|
32
39
|
catch (error) {
|
|
33
40
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
@@ -46,12 +53,18 @@ exports.executeById = executeById;
|
|
|
46
53
|
*/
|
|
47
54
|
function executeByName(params) {
|
|
48
55
|
return (settings) => __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
var _a;
|
|
49
57
|
const taskRepo = new task_1.MongoRepository(settings.connection);
|
|
50
58
|
// 未実行のタスクを取得
|
|
51
59
|
// tslint:disable-next-line:no-null-keyword
|
|
52
60
|
let task = null;
|
|
53
61
|
try {
|
|
54
|
-
task = yield taskRepo.executeOneByName(
|
|
62
|
+
task = yield taskRepo.executeOneByName({
|
|
63
|
+
name: params.name,
|
|
64
|
+
executor: {
|
|
65
|
+
name: (typeof ((_a = params.executor) === null || _a === void 0 ? void 0 : _a.name) === 'string') ? params.executor.name : DEFAULT_EXECUTOR_NAME
|
|
66
|
+
}
|
|
67
|
+
});
|
|
55
68
|
}
|
|
56
69
|
catch (error) {
|
|
57
70
|
// tslint:disable-next-line:no-single-line-block-comment
|
package/package.json
CHANGED