|
103 | 103 |
|
104 | 104 | -type builtin_command() :: {down, pid(), term()} |
|
105 | 105 | {nodeup | nodedown, node()} |
|
| 106 | + {machine_version, From :: version(), To :: version()} | |
106 | 107 | {timeout, term()}.
|
107 | 108 | %% These commands may be passed to the {@link apply/2} function in reaction
|
108 | 109 | %% to monitor effects
|
|
196 | 197 | %% used {@link ra:process_command/2} or
|
197 | 198 | %% {@link ra:process_command/3}
|
198 | 199 |
|
199 |
| --type command() :: user_command() | builtin_command(). |
| 200 | +-type command(UserCommand) :: UserCommand | builtin_command(). |
200 | 201 |
|
201 | 202 | -type command_meta_data() :: #{system_time := integer(),
|
202 | 203 | index := ra_index(),
|
|
213 | 214 | effects/0,
|
214 | 215 | reply/0,
|
215 | 216 | builtin_command/0,
|
| 217 | + command/1, |
216 | 218 | command_meta_data/0]).
|
217 | 219 |
|
218 | 220 | -optional_callbacks([tick/2,
|
|
239 | 241 |
|
240 | 242 | -callback init(Conf :: machine_init_args()) -> state().
|
241 | 243 |
|
242 |
| --callback 'apply'(command_meta_data(), command(), State) -> |
| 244 | +-callback 'apply'(command_meta_data(), command(term()), State) -> |
243 | 245 | {State, reply(), effects() | effect()} | {State, reply()} when State :: term().
|
244 | 246 |
|
245 | 247 | %% Optional callbacks
|
@@ -302,7 +304,7 @@ init({machine, _, Args} = Machine, Name, Version) ->
|
302 | 304 | Mod:init(Args#{name => Name,
|
303 | 305 | machine_version => Version}).
|
304 | 306 |
|
305 |
| --spec apply(module(), command_meta_data(), command(), State) -> |
| 307 | +-spec apply(module(), command_meta_data(), command(term()), State) -> |
306 | 308 | {State, reply(), effects()} | {State, reply()}.
|
307 | 309 | apply(Mod, Metadata, Cmd, State) ->
|
308 | 310 | Mod:apply(Metadata, Cmd, State).
|
|
0 commit comments