Skip to content

Commit

Permalink
使用bullmq重构object_webhooks功能
Browse files Browse the repository at this point in the history
  • Loading branch information
baozhoutao committed Apr 26, 2024
1 parent 31efa5b commit f154c29
Show file tree
Hide file tree
Showing 26 changed files with 449 additions and 108 deletions.
102 changes: 0 additions & 102 deletions packages/standard-objects/object_webhooks.object.yml

This file was deleted.

7 changes: 5 additions & 2 deletions services/service-cachers-manager/metadata-cachers.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
* @Author: [email protected]
* @Date: 2024-03-22 14:37:50
* @LastEditors: [email protected]
* @LastEditTime: 2024-04-12 15:17:00
* @LastEditTime: 2024-04-24 15:07:09
* @Description: 由于 collection observe 在 steedos-server.started 事件中被触发报错需要 Fiber ,添加Fiber 后, 不报错,但是无法订阅到数据. 所以单写服务处理此问题.
*
*/

"use strict";
const _ = require('lodash')
const register = require('@steedos/metadata-registrar');
const { ActionFieldUpdateCacher, WorkflowOutboundMessageCacher, WorkflowNotificationCacher, WorkflowRuleCacher, ObjectValidationRulesCacher, SettingsCacher } = require('./lib/index')
const { ActionFieldUpdateCacher, WorkflowOutboundMessageCacher, WorkflowNotificationCacher, WorkflowRuleCacher, ObjectValidationRulesCacher, SettingsCacher, ObjectWebhookCacher } = require('./lib/index')
/**
* @typedef {import('moleculer').Context} Context Moleculer's Context
* 软件包服务启动后也需要抛出事件。
Expand Down Expand Up @@ -84,6 +84,8 @@ module.exports = {

this.settingsCacher = new SettingsCacher();

this.objectWebhooksCacher = new ObjectWebhookCacher();

await this.loadMetadataWorkflows()
},

Expand All @@ -94,5 +96,6 @@ module.exports = {
this.workflowRuleCacher?.destroy();
this.objectValidationRulesCacher?.destroy();
this.settingsCacher?.destroy();
this.objectWebhooksCacher?.destroy()
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: [email protected]
* @Date: 2024-03-22 09:49:22
* @LastEditors: [email protected]
* @LastEditTime: 2024-04-15 16:39:05
* @LastEditTime: 2024-04-24 15:55:16
* @Description:
*/
const cachers = require('@steedos/cachers');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
* @Author: [email protected]
* @Date: 2024-03-22 11:23:14
* @LastEditors: [email protected]
* @LastEditTime: 2024-04-12 15:15:45
* @LastEditTime: 2024-04-24 09:30:07
* @Description:
*/
export { ActionFieldUpdateCacher } from './action_field_updates'
export { WorkflowNotificationCacher } from './workflow_notifications';
export { WorkflowOutboundMessageCacher } from './workflow_outbound_messages'
export { WorkflowRuleCacher } from './workflow_rule';
export { ObjectValidationRulesCacher } from './object_validation_rules'
export { SettingsCacher } from './settings'
export { SettingsCacher } from './settings'
export { ObjectWebhookCacher } from './object_webhook'
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* @Author: [email protected]
* @Date: 2024-04-24 09:29:28
* @LastEditors: [email protected]
* @LastEditTime: 2024-04-24 14:53:42
* @Description:
*/
import { MetadataCacherBase } from './base'

export class ObjectWebhookCacher extends MetadataCacherBase{
constructor(){
super('object_webhooks', true, {active: true});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
position: absolute
}

.relative {
position: relative
}

.sticky {
position: sticky
}
Expand All @@ -75,6 +79,10 @@
left: 0px
}

.isolate {
isolation: isolate
}

.z-20 {
z-index: 20
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: object_webhooks
label: Object Webhook
description:
fields:
name:
label: Name
help:
description:
object_name:
label: Object
help:
description:
events:
label: Events
help:
options:
- label: create
value: create
- label: update
value: update
- label: delete
value: delete
description:
fields:
label: Fields
help:
description:
payload_url:
label: Payload URL
help:
description:
content_type:
label: Format of Request
help:
description:
active:
label: Active
help:
description:
space:
label: Company
help:
description:
listviews:
all:
label: All Object Webhooks
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: object_webhooks
label: WebHooks
description:
fields:
name:
label: 名称
help:
description:
object_name:
label: 对象
help:
description:
events:
label: 何时触发
help:
options:
- label: 记录已创建
value: create
- label: 记录已更新
value: update
- label: 记录已创建或已更新
value: createAndUpdate
- label: 记录已删除
value: delete
description:
fields:
label: 推送字段
help:
description:
payload_url:
label: URL
help:
description:
content_type:
label: 请求数据格式
help:
description:
active:
label: 激活
help:
description:
space:
label: 所属工作区
help:
description:
listviews:
all:
label: 所有
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: active
label: Active
type: boolean
defaultValue: true
sort_no: 80
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: condition
type: text
sort_no: 40
is_wide: true
label: 准入条件
inlineHelpText: 指定准入条件,减少触发执行次数。最大限度地减少非必要执行次数,这将有助于节省资源。如果您创建将在记录更新时触发,我们建议先定义准入条件。然后,对于何时为更新的记录运行,选择仅在更新记录满足条件要求时选项。
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: content_type
label: Format of Request
type: text
defaultValue: '"application/json"'
hidden: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: event
type: select
label: 何时触发
required: true
multiple: false
sort_no: 30
options:
- label: 记录已创建
value: create
- label: 记录已更新
value: update
- label: 记录已创建或已更新
value: createAndUpdate
- label: 记录已删除
value: delete
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: execute_when
label: 何时运行更新记录的webhook
type: select
inlineHelpText: 您可能希望仅在将触发记录从不满足条件要求更改为满足条件要求时运行。在出现此情况时,选择第二个选项。
visible_on: ${!!condition && (event === 'update' || event === 'createAndUpdate')}
sort_no: 50
is_wide: true
options:
- label: 每次更新记录并满足条件要求
value: trueEveryTime
- label: 仅在更新记录以满足条件要求时
value: trueOnChangeOnly
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: fields
type: lookup
label: Fields
multiple: true
is_wide: true
sort_no: 60
depend_on:
- object_name
optionsFunction: !!js/function |
function(values) {
var _object, _options, fields, icon, object_name;
object_name = values.object_name;
if (!object_name) {
return [];
}
_options = [];
_object = Creator.getObject(object_name);
fields = _object.fields;
icon = _object.icon;
_.forEach(fields, function(f, k) {
return _options.push({
label: f.label || k,
value: k
});
});
return _options;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: name
type: text
label: Name
required: true
sort_no: 10
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: object_name
type: lookup
reference_to: objects
reference_to_field: name
label: Object
required: true
index: true
sort_no: 20
Loading

0 comments on commit f154c29

Please sign in to comment.