doumengjing1500 2014-10-08 00:00
浏览 3

交易和实体组

Let me try and describe the requirement.

My product has many sites, each sites have many warehouses, and each warehouse has a count of a important resource it is responsible for.

Whenever someone wants that resource, I want to efficiently pick a (site, warehouse) which will fulfill the requirement (based on some heuristics.)

I reckon I need a transaction over such a operation (as I do not want to leave things in a messy state.)

I have gone over the documentation many times and understand that entity groups are the recommended way of doing transactions.

From Google AppEngine Go documentation:

An entity's parent, parent's parent, and so on recursively, are its ancestors; its children, children's children, and so on, are its descendants. An entity and its descendants are said to belong to the same entity group.

If I make it so that each warehouse has a site as an ancestor, I can get good control when operating on warehouses under the same site (i.e. entity group.)

What is the simple approach of making the operation safe across all sites and their warehouses?

Approaches I have thought of:

  • Make all sites under a virtual parent, but does that allow me to operate on W1 (a warehouse under site S1) and W2 (a warehouse under site S2) transactionally? In other words, are W1 and W2 in one entity group because their own ancestors have the same parent?
  • Make all warehouses under a virtual parent, and take the compromise as then all the warehouses are in the same entity group.

Is it just me or the meaning of entity group slightly up for interpretation as per the docs?

PS: The number of such safe operations required is relatively low, so I am not too worried about the limited write throughput of having things under one entity group.

  • 写回答

1条回答 默认 最新

  • douningchang3610 2014-10-08 00:16
    关注

    The answer to your question is yes, entities belong to the same group if they have the same parent, even if that parent is a grand-parent for one or both of these entities:

    Every entity with a given root entity as an ancestor is in the same entity group.

    From: Transactions

    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么