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.