Alec Henninger

01/31/2023, 9:58 PM
Anyone have experience modeling limited seat type licenses in spicedb? For example, say there is user which can be given an entitled relation to a resource, and access is gated on being entitled. However, let's say only 10 users can be assigned that relation. My first thought is to use a caveat (current < max), passing in the current value as context, but I'm not sure if there is a nice/fast way to (1) count the number of existing relations and (2) defeat race conditions (e.g. two requests ask for the 10th relation at the same time, both see 9 current, and the result is 11 users entitled) .