@@ -89,14 +89,27 @@ The timeout is optional and defaults to 5000ms.
8989
9090 Types:
9191 Args = term()
92- Result = {ok, State} | {stop, Reason}
93- State = term(),
92+ Result = {ok, State} |
93+ {ok, State, {continue, Continue}} |
94+ ignore |
95+ {stop, Reason}
96+ State = term()
97+ Continue = term()
9498 Reason = term()
9599
96-
97100Called whenever a ` gen_batch_server ` is started with the arguments provided
98101to ` start_link/4 ` .
99102
103+ Returning ` {ok, State, {continue, Continue}} ` will cause ` handle_continue/2 `
104+ to be called before processing any messages.
105+
106+ Returning ` ignore ` will cause ` start_link ` to return ` ignore ` and the process
107+ will exit normally without a crash report.
108+
109+ Can be used in scenarios where a ` gen_batch_server `
110+ depends on a resource that can be temporarily
111+ unavailable (e.g. when a Ra member runs out of disk space).
112+
100113#### Module: handle_batch (Batch, State) -> Result.
101114
102115 Types:
@@ -105,7 +118,11 @@ to `start_link/4`.
105118 Op = {cast, UserOp} |
106119 {call, from(), UserOp} |
107120 {info, UserOp}.
108- Result = {ok, State} | {ok, Actions, State} | {stop, Reason}
121+ Result = {ok, State} |
122+ {ok, State, {continue, Continue}} |
123+ {ok, Actions, State} |
124+ {ok, Actions, State, {continue, Continue}} |
125+ {stop, Reason}
109126 State = term()
110127 From = {Pid :: pid(), Tag :: reference()}
111128 Action = {reply, From, Msg} | garbage_collect
@@ -115,6 +132,24 @@ to `start_link/4`.
115132Called whenever a new batch is ready for processing. The implementation can
116133optionally return a list of reply actions used to reply to ` call ` operations.
117134
135+ #### Module: handle_continue (Continue, State) -> Result
136+
137+ Types:
138+ Continue = term()
139+ State = term()
140+ Result = {ok, NewState} |
141+ {ok, NewState, {continue, NewContinue}} |
142+ {stop, Reason}
143+ NewState = term()
144+ NewContinue = term()
145+ Reason = term()
146+
147+ Optional. Called after ` init/1 ` returns ` {ok, State, {continue, Continue}} ` or
148+ after ` handle_batch/2 ` returns with a ` {continue, Continue} ` tuple.
149+
150+ Most useful for post-` init/2 ` work that needs
151+ the server to be registered first.
152+
118153#### Module: terminate (Reason, State) -> Result
119154
120155 Types:
@@ -138,4 +173,3 @@ Optional. Used to provide a custom formatting of the user state.
138173# Copyright
139174
140175(c) 2018-2023 Broadcom. All Rights Reserved. The term Broadcom refers to Broadcom Inc. and/or its subsidiaries.
141-
0 commit comments