Skip to content

Commit 58b162b

Browse files
authored
Merge pull request #544 from rabbitmq/export-ra-machine-command-spec
Add command/1 type and export
2 parents 1009f77 + e1ecb94 commit 58b162b

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/ra_machine.erl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103

104104
-type builtin_command() :: {down, pid(), term()} |
105105
{nodeup | nodedown, node()} |
106+
{machine_version, From :: version(), To :: version()} |
106107
{timeout, term()}.
107108
%% These commands may be passed to the {@link apply/2} function in reaction
108109
%% to monitor effects
@@ -196,7 +197,7 @@
196197
%% used {@link ra:process_command/2} or
197198
%% {@link ra:process_command/3}
198199

199-
-type command() :: user_command() | builtin_command().
200+
-type command(UserCommand) :: UserCommand | builtin_command().
200201

201202
-type command_meta_data() :: #{system_time := integer(),
202203
index := ra_index(),
@@ -213,6 +214,7 @@
213214
effects/0,
214215
reply/0,
215216
builtin_command/0,
217+
command/1,
216218
command_meta_data/0]).
217219

218220
-optional_callbacks([tick/2,
@@ -239,7 +241,7 @@
239241

240242
-callback init(Conf :: machine_init_args()) -> state().
241243

242-
-callback 'apply'(command_meta_data(), command(), State) ->
244+
-callback 'apply'(command_meta_data(), command(term()), State) ->
243245
{State, reply(), effects() | effect()} | {State, reply()} when State :: term().
244246

245247
%% Optional callbacks
@@ -302,7 +304,7 @@ init({machine, _, Args} = Machine, Name, Version) ->
302304
Mod:init(Args#{name => Name,
303305
machine_version => Version}).
304306

305-
-spec apply(module(), command_meta_data(), command(), State) ->
307+
-spec apply(module(), command_meta_data(), command(term()), State) ->
306308
{State, reply(), effects()} | {State, reply()}.
307309
apply(Mod, Metadata, Cmd, State) ->
308310
Mod:apply(Metadata, Cmd, State).

test/ra_fifo.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
{discard, MsgIds :: [msg_id()], Customer :: customer_id()} |
9898
purge.
9999

100-
-type command() :: protocol() | ra_machine:builtin_command().
100+
-type command() :: ra_machine:command(protocol()).
101101
%% all the command types supported by ra fifo
102102

103103
-type client_msg() :: delivery().

0 commit comments

Comments
 (0)