From 0c05b3f01981b8ae29bb06cc235bfa405fde6373 Mon Sep 17 00:00:00 2001 From: Andrew Mayorov Date: Wed, 17 Jul 2024 16:21:33 +0200 Subject: [PATCH] fix(ds): make conditionals less confusing --- apps/emqx_durable_storage/src/emqx_ds.erl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/emqx_durable_storage/src/emqx_ds.erl b/apps/emqx_durable_storage/src/emqx_ds.erl index d745c8c74..1bf72dc59 100644 --- a/apps/emqx_durable_storage/src/emqx_ds.erl +++ b/apps/emqx_durable_storage/src/emqx_ds.erl @@ -113,14 +113,15 @@ | {delete, message(_)}. %% Precondition. -%% Fails whole batch if the message in question does not match (`while'), or -%% does match (`unless'). Here "match" means that it either just exists (when -%% pattern is '_') or has exactly the same payload, rest of the message fields are -%% irrelevant. Useful to construct batches with "compare-and-set" semantics. +%% Fails whole batch if the storage already has the matching message (`if_exists'), +%% or does not yet have (`unless_exists'). Here "matching" means that it either +%% just exists (when pattern is '_') or has exactly the same payload, rest of the +%% message fields are irrelevant. +%% Useful to construct batches with "compare-and-set" semantics. %% Note: backends may not support this, but if they do only DBs with `atomic_batches' %% enabled are expected to support preconditions in batches. -type precondition() :: - {while | unless, message(iodata() | '_')}. + {if_exists | unless_exists, message(iodata() | '_')}. -type rank_x() :: term().