Database 如何在实体流经系统时存储与实体匹配的属性匹配规则对象?
我需要帮助找出一种存储(以及稍后检索/匹配)动态规则的好方法,这些规则可用于在对象流经工作流系统时匹配对象 在这个场景中,我正在构建一个系统,在对象最终准备好存储在另一个API中供以后使用之前,将对发布到该系统中的对象执行一系列步骤。这些步骤需要管理员进行配置;系统应该允许他们说“如果一个对象通过ABC属性,那么对它执行XYZ操作”。以下是系统流程的基本概念:Database 如何在实体流经系统时存储与实体匹配的属性匹配规则对象?,database,amazon-web-services,design-patterns,database-design,nosql,Database,Amazon Web Services,Design Patterns,Database Design,Nosql,我需要帮助找出一种存储(以及稍后检索/匹配)动态规则的好方法,这些规则可用于在对象流经工作流系统时匹配对象 在这个场景中,我正在构建一个系统,在对象最终准备好存储在另一个API中供以后使用之前,将对发布到该系统中的对象执行一系列步骤。这些步骤需要管理员进行配置;系统应该允许他们说“如果一个对象通过ABC属性,那么对它执行XYZ操作”。以下是系统流程的基本概念: +-------+ +-----------+ +-----------+ +-----------+ +-----------+ +
+-------+ +-----------+ +-----------+ +-----------+ +-----------+ +-------+
| | | | | | | | | | | |
| +--> Ruleset 1 +-> Ruleset 2 +-> Ruleset 3 +-> Object +-> |
| | | | | | | | | Storage | | |
| Input | +-----+-----+ +------+----+ +-----+-----+ +-----------+ | Final |
| API | ^ ^ ^ | API |
| | +-----+--------------+------------+-----+ | |
| | | Rule | | |
| | | Management | | |
+-------+ +---------------------------------------+ +-------+
Entity 1 {
type: "widget",
category: "toys",
manufacturer: "Acme",
price: 5,
}
Entity 2 {
type: "widget",
category: "kitchen",
manufacturer: "Acme",
price: 6,
}
Entity 3 {
type: "gadget",
category: "tools",
manufacturer: "XYZ Co",
price: 10,
}
对象与配置规则的匹配需要基于属性(如下例所示)。也就是说,管理规则的人员需要能够提供一个或多个属性名称以及该属性的值,并且系统需要在具有该属性名称/值组合的对象通过该规则时运行该规则。此外,无论何时创建或编辑规则,我们都需要能够找到与新的/编辑的规则匹配的所有已持久化对象
例如,考虑以下规则已被配置:
Rule 1 {
priority: 10,
$match: {
type: "gadget",
},
$set: {
priceIncrease: 1.2,
}
}
Rule 2 {
priority: 10,
$match: {
type: "widget",
},
$set: {
priceIncrease: 1.1,
}
}
Rule 3 {
priority: 100,
$match: {
type: "widget",
category: "kitchen",
},
$set: {
priceIncrease: 1.15,
}
}
然后,以下三个实体通过系统:
+-------+ +-----------+ +-----------+ +-----------+ +-----------+ +-------+
| | | | | | | | | | | |
| +--> Ruleset 1 +-> Ruleset 2 +-> Ruleset 3 +-> Object +-> |
| | | | | | | | | Storage | | |
| Input | +-----+-----+ +------+----+ +-----+-----+ +-----------+ | Final |
| API | ^ ^ ^ | API |
| | +-----+--------------+------------+-----+ | |
| | | Rule | | |
| | | Management | | |
+-------+ +---------------------------------------+ +-------+
Entity 1 {
type: "widget",
category: "toys",
manufacturer: "Acme",
price: 5,
}
Entity 2 {
type: "widget",
category: "kitchen",
manufacturer: "Acme",
price: 6,
}
Entity 3 {
type: "gadget",
category: "tools",
manufacturer: "XYZ Co",
price: 10,
}
当每个实体流经系统时,以下是匹配项:
- 关系数据库(Aurora)
- NoSQL键/值(DynamoDB/Redis)
- 图形数据库(海王星)
谢谢 你需要提供一个mcve::@Kumar我不知道如何才能为这个提供mcve。这不是编码问题,而是设计问题。你能解释一下为什么你认为它需要一个MCVE,我会怎么做吗?另外,如果你否决了这个问题,你能重新考虑一下吗?