You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A verification function that will check the given value is correct. It is trigger for verifying the initial values, including the default value, and before updated values are applied.
66
+
- If it is set to `none`, all values are allowed.
67
+
- If it is set to a list of values, any given value checks that the new value is in such allowlist.
68
+
- If it is an `mfa`, the given function will be called on the given value. This function
69
+
must be pure and return a boolean or a `{true, NewValue} | {false, Reason}`. It can also be used for preprocessing of the input value by returning `{true, NewValue}`.
70
+
71
+
### `update`
72
+
***Syntax:**`read_only`, `none`, or an `mfa` of arity 2
73
+
***Example:**`update = {?MODULE, update, 2}`
74
+
***Default:**`read_only`
75
+
76
+
An action to take when the value of this variable is updated. It is triggered at runtime when updates to the value are applied.
77
+
- If it is set to `read_only`, updates will fail.
78
+
- If it is set to `none`, all updates are allowed.
79
+
- If it is an `mfa`, the given function will be called on the old and new value.
80
+
81
+
## Reasonale
34
82
35
83
NB: the reason why the `-required_variable(...)` is preferred over the usual behaviour
36
84
callback is because the orchestration tools can easily extract the attributes even
@@ -46,7 +94,7 @@ compilation of the module. As an example, a module:
46
94
cannot be compiled without the ``some_unavailable_header.hrl`` file, but we still
47
95
can parse it and extract the attributes:
48
96
```
49
-
Eshell V10.3 (abort with ^G)
97
+
Eshell V14.0 (press Ctrl+G to abort, type help(). for help)
50
98
1> c(example).
51
99
example.erl:2: can't find include file "some_unavailable_header.hrl"
Copy file name to clipboardExpand all lines: guides/coordinator.md
+4-44Lines changed: 4 additions & 44 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,6 @@
1
-
#amoc_coordinator
1
+
## API
2
2
3
-
## Module
4
-
5
-
`amoc_coordinator`
3
+
See `amoc_coordinator`.
6
4
7
5
## Description
8
6
@@ -20,8 +18,8 @@ If more then one of the *Coordination Items* matching the `NumberOfUsers` is tri
20
18
For example if the *Coordination Plan* is `[{2, Act1}, {3, Act2}]` then on the 6th user calling `add`, `Act1` will be called with 2 users passed and `Act2` will be called with 3 users passed.
21
19
22
20
*Coordination Actions* may be one of the following:
23
-
-`fun(Event) -> any()` - this type of action does not care about particular users, but only about the number of them;
24
-
-`fun(Event, ListOfUsersData) -> any()` - this type of action gets `ListOfUsersData` which is a list of `{Pid, Data}` tuples with `Pid`s passed by users calling `amoc_coordinator:add/2` or `amoc_coordinator:add/3`;
21
+
-`fun(Event) -> any()` - this type of action does not care about particular users, but only about the number of them;
22
+
-`fun(Event, ListOfUsersData) -> any()` - this type of action gets `ListOfUsersData` which is a list of `{Pid, Data}` tuples with `Pid`s passed by users calling `amoc_coordinator:add/2` or `amoc_coordinator:add/3`;
25
23
-`fun(Event, User1, User2) -> any()` - this type of action gets `distinct pairs` from the batch of users `User1` and `User2` which are `{Pid, Data}` tuples with `Pid`s passed by users calling `amoc_coordinator:add/2` or `amoc_coordinator:add/3`;
26
24
27
25
where an `Event` is a `{EventType, NumOfUsers}` tuple, in which `NumOfUsers` is the number of users passed to the event.
@@ -37,44 +35,6 @@ It’s guaranteed that all the *Coordination Actions* with `all` are executed af
37
35
- Eg. for `[a, b]`, the `distinct pairs` collection is `[{a, b}]`;
38
36
- Eg. for `[a, b, c]`, the `distinct pairs` collection is `[{a, b}, {a, c}, {b, c}]`.
39
37
40
-
## Exports
41
-
42
-
#### `start(CoordinatorName, CoordinationPlan) -> ok | error`
43
-
#### `start(CoordinatorName, CoordinationPlan, Timeout) -> ok | error`
44
-
45
-
##### Types
46
-
```erlang
47
-
CoordinatorName::atom()
48
-
CoordinationPlan:: [ CoordinationItem ]
49
-
CoordinationItem:: {NumberOfUsers::pos_integer() | all, CoordinationActions}
0 commit comments