6262-export_type ([
6363 storage_handle / 0 ,
6464 metadata / 0 ,
65- error / 0 ,
6665 status / 0
6766]).
6867
126125% % Issue a read command to get the label associated with the most
127126% % recent command that was applied with a label. See the optional
128127% % callback `storage_apply/4` for details.
129- -callback storage_label (Handle :: storage_handle ()) -> {ok , Label :: wa_raft_label :label ()} | error () .
128+ -callback storage_label (Handle :: storage_handle ()) -> {ok , Label :: wa_raft_label :label ()} | { error , Reason :: term ()} .
130129-optional_callbacks ([storage_label / 1 ]).
131130
132131
190189% % If the command could not be applied in a manner so as to preserve the
191190% % desired consistency guarantee then implementations can raise an error to be
192191% % aborted safely.
193- -callback storage_apply_config (Config :: wa_raft_server :config (), Position :: wa_raft_log :log_pos (), Handle :: storage_handle ()) -> {Result :: ok | error () , NewHandle :: storage_handle ()}.
192+ -callback storage_apply_config (Config :: wa_raft_server :config (), Position :: wa_raft_log :log_pos (), Handle :: storage_handle ()) -> {Result :: ok | { error , Reason :: term ()} , NewHandle :: storage_handle ()}.
194193
195194% %-----------------------------------------------------------------------------
196195% % RAFT Storage Provider - Read Commands
233232% % producing a directory tree rooted at the provided path that represents the
234233% % current storage state. The produced snapshot should retain the current
235234% % position when loaded.
236- -callback storage_create_snapshot (Path :: file :filename (), Handle :: storage_handle ()) -> ok | error () .
235+ -callback storage_create_snapshot (Path :: file :filename (), Handle :: storage_handle ()) -> ok | { error , Reason :: term ()} .
237236
238237% % Create a new witness snapshot at the provided path which must contain the current
239238% % position in storage and configuration.
240239% % The snapshot will be empty (without actual storage data) but will retain all
241240% % necessary metadata. When loaded, this witness snapshot will reflect the exact
242241% % position state of the original storage without the storage contents.
243- -callback storage_create_witness_snapshot (Path :: file :filename (), Handle :: storage_handle ()) -> ok | error () .
242+ -callback storage_create_witness_snapshot (Path :: file :filename (), Handle :: storage_handle ()) -> ok | { error , Reason :: term ()} .
244243-optional_callback ([storage_create_witness_snapshot / 2 ]).
245244
246245% % Load a snapshot previously created by the same storage provider, possibly
249248% % If a recoverable error occured, the storage state should remain unchanged.
250249% % If the storage state is no longer suitable for use, an error should be
251250% % raised.
252- -callback storage_open_snapshot (Path :: file :filename (), ExpectedPosition :: wa_raft_log :log_pos (), Handle :: storage_handle ()) -> {ok , NewHandle :: storage_handle ()} | error () .
251+ -callback storage_open_snapshot (Path :: file :filename (), ExpectedPosition :: wa_raft_log :log_pos (), Handle :: storage_handle ()) -> {ok , NewHandle :: storage_handle ()} | { error , Reason :: term ()} .
253252
254253% %-----------------------------------------------------------------------------
255254% % RAFT Storage Provider - Bootstrapping
262261% % version and the config as the value. Extra data may be used by implementors
263262% % to provide extra state via arguments to external APIs that use this
264263% % endpoint, such as the partition bootstrapping API.
265- -callback storage_make_empty_snapshot (Options :: # raft_options {}, Path :: file :filename (), Position :: wa_raft_log :log_pos (), Config :: wa_raft_server :config (), Data :: dynamic ()) -> ok | error () .
264+ -callback storage_make_empty_snapshot (Options :: # raft_options {}, Path :: file :filename (), Position :: wa_raft_log :log_pos (), Config :: wa_raft_server :config (), Data :: dynamic ()) -> ok | { error , Reason :: term ()} .
266265-optional_callback ([storage_make_empty_snapshot / 5 ]).
267266
268267% %-----------------------------------------------------------------------------
271270
272271-type metadata () :: config | atom ().
273272-type storage_handle () :: dynamic ().
274- -type error () :: {error , term ()}.
275273
276274-type status () :: [status_element ()].
277275-type status_element () ::
@@ -381,11 +379,11 @@ status(Storage) ->
381379position (Storage ) ->
382380 gen_server :call (Storage , ? POSITION_REQUEST , ? RAFT_STORAGE_CALL_TIMEOUT ()).
383381
384- -spec label (Storage :: gen_server :server_ref ()) -> {ok , Label :: wa_raft_label :label ()} | wa_raft_storage : error () .
382+ -spec label (Storage :: gen_server :server_ref ()) -> {ok , Label :: wa_raft_label :label ()} | { error , Reason :: term ()} .
385383label (Storage ) ->
386384 gen_server :call (Storage , ? LABEL_REQUEST , ? RAFT_STORAGE_CALL_TIMEOUT ()).
387385
388- -spec config (Storage :: gen_server :server_ref ()) -> {ok , wa_raft_log :log_pos (), wa_raft_server :config ()} | undefined | wa_raft_storage : error () .
386+ -spec config (Storage :: gen_server :server_ref ()) -> {ok , wa_raft_log :log_pos (), wa_raft_server :config ()} | undefined | { error , Reason :: term ()} .
389387config (Storage ) ->
390388 gen_server :call (Storage , ? CONFIG_REQUEST , ? RAFT_STORAGE_CALL_TIMEOUT ()).
391389
@@ -418,39 +416,39 @@ apply(Storage, Record, Size, EffectiveTerm) ->
418416apply_read (Storage , From , Command ) ->
419417 gen_server :cast (Storage , ? APPLY_READ_REQUEST (From , Command )).
420418
421- -spec open_snapshot (Storage :: gen_server :server_ref (), Path :: file :filename (), Position :: wa_raft_log :log_pos ()) -> ok | error () .
419+ -spec open_snapshot (Storage :: gen_server :server_ref (), Path :: file :filename (), Position :: wa_raft_log :log_pos ()) -> ok | { error , Reason :: term ()} .
422420open_snapshot (Storage , Path , Position ) ->
423421 gen_server :call (Storage , ? OPEN_SNAPSHOT_REQUEST (Path , Position ), ? RAFT_STORAGE_CALL_TIMEOUT ()).
424422
425- -spec create_snapshot (Storage :: gen_server :server_ref ()) -> {ok , Pos :: wa_raft_log :log_pos ()} | error () .
423+ -spec create_snapshot (Storage :: gen_server :server_ref ()) -> {ok , Pos :: wa_raft_log :log_pos ()} | { error , Reason :: term ()} .
426424create_snapshot (Storage ) ->
427425 gen_server :call (Storage , ? CREATE_SNAPSHOT_REQUEST (), ? RAFT_STORAGE_CALL_TIMEOUT ()).
428426
429427% % Be careful when using the same name for two snapshots as the RAFT storage
430428% % server will not recreate an existing snapshot even if the storage state has
431429% % advanced since the snapshot was created; however, this method will always
432430% % return the current position upon success.
433- -spec create_snapshot (Storage :: gen_server :server_ref (), Name :: string ()) -> {ok , Pos :: wa_raft_log :log_pos ()} | error () .
431+ -spec create_snapshot (Storage :: gen_server :server_ref (), Name :: string ()) -> {ok , Pos :: wa_raft_log :log_pos ()} | { error , Reason :: term ()} .
434432create_snapshot (Storage , Name ) ->
435433 gen_server :call (Storage , ? CREATE_SNAPSHOT_REQUEST (Name ), ? RAFT_STORAGE_CALL_TIMEOUT ()).
436434
437- -spec create_witness_snapshot (Storage :: gen_server :server_ref ()) -> {ok , Pos :: wa_raft_log :log_pos ()} | error () .
435+ -spec create_witness_snapshot (Storage :: gen_server :server_ref ()) -> {ok , Pos :: wa_raft_log :log_pos ()} | { error , Reason :: term ()} .
438436create_witness_snapshot (Storage ) ->
439437 gen_server :call (Storage , ? CREATE_WITNESS_SNAPSHOT_REQUEST (), ? RAFT_STORAGE_CALL_TIMEOUT ()).
440438
441439% % Be careful when using the same name for two snapshots as the RAFT storage
442440% % server will not recreate an existing snapshot even if the storage state has
443441% % advanced since the snapshot was created; however, this method will always
444442% % return the current position upon success.
445- -spec create_witness_snapshot (Storage :: gen_server :server_ref (), Name :: string ()) -> {ok , Pos :: wa_raft_log :log_pos ()} | error () .
443+ -spec create_witness_snapshot (Storage :: gen_server :server_ref (), Name :: string ()) -> {ok , Pos :: wa_raft_log :log_pos ()} | { error , Reason :: term ()} .
446444create_witness_snapshot (Storage , Name ) ->
447445 gen_server :call (Storage , ? CREATE_WITNESS_SNAPSHOT_REQUEST (Name ), ? RAFT_STORAGE_CALL_TIMEOUT ()).
448446
449447-spec delete_snapshot (Storage :: gen_server :server_ref (), Name :: string ()) -> ok .
450448delete_snapshot (Storage , Name ) ->
451449 gen_server :cast (Storage , ? DELETE_SNAPSHOT_REQUEST (Name )).
452450
453- -spec make_empty_snapshot (Storage :: gen_server :server_ref (), Path :: file :filename (), Position :: wa_raft_log :log_pos (), Config :: wa_raft_server :config (), Data :: term ()) -> ok | error () .
451+ -spec make_empty_snapshot (Storage :: gen_server :server_ref (), Path :: file :filename (), Position :: wa_raft_log :log_pos (), Config :: wa_raft_server :config (), Data :: term ()) -> ok | { error , Reason :: term ()} .
454452make_empty_snapshot (Storage , Path , Position , Config , Data ) ->
455453 gen_server :call (Storage , ? MAKE_EMPTY_SNAPSHOT_REQUEST (Path , Position , Config , Data ), ? RAFT_STORAGE_CALL_TIMEOUT ()).
456454
@@ -730,7 +728,7 @@ handle_delayed_reads(#state{queues = Queues, module = Module, handle = Handle, p
730728 ],
731729 ok .
732730
733- -spec handle_create_snapshot (SnapshotName :: string (), Storage :: # state {}) -> {ok , wa_raft_log :log_pos ()} | error () .
731+ -spec handle_create_snapshot (SnapshotName :: string (), Storage :: # state {}) -> {ok , wa_raft_log :log_pos ()} | { error , Reason :: term ()} .
734732handle_create_snapshot (SnapshotName , # state {name = Name , path = Path , module = Module , handle = Handle , position = Position } = State ) ->
735733 SnapshotPath = filename :join (Path , SnapshotName ),
736734 case filelib :is_dir (SnapshotPath ) of
@@ -748,7 +746,7 @@ handle_create_snapshot(SnapshotName, #state{name = Name, path = Path, module = M
748746 end
749747 end .
750748
751- -spec handle_create_witness_snapshot (SnapshotName :: string (), Storage :: # state {}) -> {ok , wa_raft_log :log_pos ()} | error () .
749+ -spec handle_create_witness_snapshot (SnapshotName :: string (), Storage :: # state {}) -> {ok , wa_raft_log :log_pos ()} | { error , Reason :: term ()} .
752750handle_create_witness_snapshot (SnapshotName , # state {name = Name , path = Path , module = Module , handle = Handle , position = Position } = State ) ->
753751 SnapshotPath = filename :join (Path , SnapshotName ),
754752 case filelib :is_dir (SnapshotPath ) of
0 commit comments