bquarp v0.3.0 Reactivity.Quality.Context View Source
Essential operations on message contexts. For every guarantee, the functions combine, penalty and transform need to be implemented. Guarantees with obvious context-progression (e.g. with counters) should implement new_context_obs.
Link to this section Summary
Functions
1) Combines a list of contexts
Creates an observable carrying the contexts for the respective values of a given observable under the given guarantee.
calculates the penalty of a context.
Decides whether the given intermediate contexts are of acceptable quality for given guarantees.
Transforms a list of intermediate contexts into finalized (i.e. plain) contexts according to their respective guarantees and by means of the given transformation data
Link to this section Functions
combine(contexts, guaranteess) View Source
1) Combines a list of contexts
In the case of causality:
- Takes a list of contexts [c] (with c = path = [tree | [{node, counter}]] | [{node, counter}])
- Returns an intermediate causality context i = [c] -> Just leaves the list 'as is'.
In the case of glitch-freedom:
- Takes a list of contexts [[{source, counter(s)}]] with counter(s) = counter | {lowest_counter, highest_counter}
- Returns a an intermediate glitch-freedom context [{source, counter(s)}] -> For each source, the lowest and highest counter gets recalculated from all the tuples {source, counter(s)} with that source. If those are the same, only one counter value is present. E.g.: [{:a, 5}, {:a, 4}, {:b, 11}, {:c, {1, 2}}, {:c, 3}] -> [{:a, {4, 5}}, {:b, 11}, {:c, {1, 3}}]
In the case of time-synchronization:
- Takes a list of time-synchronization contexts [stamp(s)] with stamp(s) = stamp | {lowest_stamp, highest_stamp}
- Returns an intermediate time-synchronization context -> The lowest and highest timestamp get recalculated from all the stamp(s)s in the list. E.g.: [{4, 5}, 2, 3, {3, 6}] -> {2, 6}
2) Combines multiple lists of contexts of possibly different consistency guarantees This happens by combining the contexts pertaining to each occurring guarantee type separately.
- Takes:
* a list of context lists [[c]]]
* a list of guarantee lists [[g]]]
- Returns a list of intermediate contexts [i]
new_context_obs(obs, arg) View Source
Creates an observable carrying the contexts for the respective values of a given observable under the given guarantee.
In the case of causality: The source node identifier and a counter value: {s, c}
In the case of glitch-freedom: The source node identifier and a counter value: {s, c}
In the case of time-synchronization: A counter value c
penalty(i, arg2) View Source
calculates the penalty of a context.
In the case of causality: Compares paths/trees in the context two by two and takes the maximum penalty from all comparisons Two paths/trees may have a nonzero penalty if one is a prefix of the other. Then we must compare the counter produced by the last shared node in order to determine if the longer path does not reflect a later update than the prefix path, violating causality.
In the case of glitch-freedom: Takes a context of the form [{si, ci}] with si = counter_i | {lowest_counter_i, highest_counter_i} And returns the maximum difference between counters attached to the same source.
In the case of time-synchronization: Takes a context of the form t or {t_low, t_high} and calculates the difference.
sufficient_quality?(i, arg2) View Source
Decides whether the given intermediate contexts are of acceptable quality for given guarantees.
Takes
- A list of intermediate ontexts [i]
- A list of associated guarantees [g] for the respective contexts
- Returns whether the list of contexts is acceptable (true or false) -> The given list of intermediate contexts is of sufficient quality if for every context, its penalty under the associated guarantee is less than or equal to the margin of that guarantee.
transform(i, trans, arg3) View Source
Transforms a list of intermediate contexts into finalized (i.e. plain) contexts according to their respective guarantees and by means of the given transformation data
In the case of causality: The transformation data is of the form {node, counter} If the context is a path of nodes [{node, counter}], just append the transformation data, completing the path. If the context is a list of paths, that list is the first node of a new path, and the transformation data gets appended as the second node, completing the path.
In the case of glitch-freedom: The transformation is the identity map
In the case of time-synchronization: The transformation is the identity map