Packages
brod
3.19.0
4.5.7
4.5.6
4.5.5
4.5.4
4.5.3
4.5.2
4.5.1
4.5.0
4.4.7
4.4.6
4.4.5
4.4.4
4.4.3
4.4.2
4.4.1
4.4.0
4.3.3
4.3.2
4.3.1
4.3.0
4.2.0
4.1.1
4.1.0
4.0.0
3.19.1
3.19.0
3.18.0
3.17.1
3.17.0
3.16.5
3.16.4
3.16.3
3.16.2
3.16.1
3.16.0
3.15.6
3.15.5
3.15.4
3.15.3
3.15.1
3.15.0
3.14.0
3.13.0
3.12.0
3.11.0
3.10.0
3.9.5
3.9.3
3.9.2
3.9.1
3.9.0
3.8.1
3.8.0
3.7.11
3.7.10
3.7.9
3.7.8
3.7.7
3.7.6
3.7.5
3.7.4
3.7.3
3.7.2
3.7.1
3.7.0
3.6.2
3.6.1
3.6.0
3.5.2
3.5.1
3.5.0
3.4.0
3.3.5
3.3.4
3.3.3
3.3.2
3.3.1
3.3.0
3.2.0
3.0.0
2.5.0
2.4.1
2.4.0
2.3.7
2.3.6
2.3.5
2.3.4
2.3.3
2.3.1
2.2.16
2.2.15
2.2.14
2.2.12
2.2.11
2.2.10
2.2.9
2.2.8
2.2.7
2.2.6
2.2.5
2.2.4
2.2.3
2.2.2
2.2.1
2.2.0
2.1.12
2.1.11
2.1.10
2.1.8
2.1.7
2.1.4
2.1.2
2.0.0
Apache Kafka Erlang client library
Current section
113 Versions
Jump to
Current section
113 Versions
Compare versions
4
files changed
+26
additions
-6
deletions
| @@ -29,4 +29,4 @@ | |
| 29 29 | [{<<"app">>,<<"snappyer">>}, |
| 30 30 | {<<"optional">>,false}, |
| 31 31 | {<<"requirement">>,<<"1.2.9">>}]}]}. |
| 32 | - {<<"version">>,<<"3.18.0">>}. |
| 32 | + {<<"version">>,<<"3.19.0">>}. |
| @@ -1,6 +1,6 @@ | |
| 1 1 | {application,brod, |
| 2 2 | [{description,"Apache Kafka Erlang client library"}, |
| 3 | - {vsn,"3.18.0"}, |
| 3 | + {vsn,"3.19.0"}, |
| 4 4 | {registered,[]}, |
| 5 5 | {applications,[kernel,stdlib,kafka_protocol,snappyer]}, |
| 6 6 | {env,[]}, |
| @@ -22,7 +22,7 @@ | |
| 22 22 | -include("brod_int.hrl"). |
| 23 23 | |
| 24 24 | %% brod_topic_subscriber callbacks |
| 25 | - -export([init/2, handle_message/3, terminate/2]). |
| 25 | + -export([init/2, handle_message/3, handle_info/2, terminate/2]). |
| 26 26 | |
| 27 27 | -type start_options() :: |
| 28 28 | #{ group_id := brod:group_id() |
| @@ -91,6 +91,15 @@ handle_message(_Partition, Msg, State) -> | |
| 91 91 | {ok, NewState} |
| 92 92 | end. |
| 93 93 | |
| 94 | + handle_info(Info, #state{cb_module = CbModule , cb_state = CbState} = State) -> |
| 95 | + %% Any unhandled messages are forwarded to the callback module to |
| 96 | + %% support arbitrary message-passing. |
| 97 | + %% Only the {noreply, State} return value is supported. |
| 98 | + case brod_utils:optional_callback(CbModule, handle_info, [Info, CbState], {noreply, CbState}) of |
| 99 | + {noreply, NewCbState} -> |
| 100 | + {noreply, State#state{cb_state = NewCbState}} |
| 101 | + end. |
| 102 | + |
| 94 103 | terminate(Reason, #state{cb_module = CbModule, cb_state = State}) -> |
| 95 104 | brod_utils:optional_callback(CbModule, terminate, [Reason, State], ok). |
| @@ -108,7 +108,12 @@ | |
| 108 108 | %% This callback is called before stopping the subscriber |
| 109 109 | -callback terminate(_Reason, cb_state()) -> _. |
| 110 110 | |
| 111 | - -optional_callbacks([terminate/2]). |
| 111 | + %% This callback is called when the subscriber receives a message unrelated to |
| 112 | + %% the subscription. |
| 113 | + %% The callback must return `{noreply, NewCallbackState}'. |
| 114 | + -callback handle_info(_Msg, cb_state()) -> {noreply, cb_state()}. |
| 115 | + |
| 116 | + -optional_callbacks([terminate/2, handle_info/2]). |
| 112 117 | |
| 113 118 | %%%_* Types and macros ========================================================= |
| 114 119 | |
| @@ -357,8 +362,14 @@ handle_info({'DOWN', _Mref, process, Pid, Reason}, | |
| 357 362 | %% not a consumer pid |
| 358 363 | {noreply, State} |
| 359 364 | end; |
| 360 | - handle_info(_Info, State) -> |
| 361 | - {noreply, State}. |
| 365 | + handle_info(Info, #state{cb_module = CbModule, cb_state = CbState} = State) -> |
| 366 | + %% Any unhandled messages are forwarded to the callback module to |
| 367 | + %% support arbitrary message-passing. |
| 368 | + %% Only the {noreply, State} return value is supported. |
| 369 | + case brod_utils:optional_callback(CbModule, handle_info, [Info, CbState], {noreply, CbState}) of |
| 370 | + {noreply, NewCbState} -> |
| 371 | + {noreply, State#state{cb_state = NewCbState}} |
| 372 | + end. |
| 362 373 | |
| 363 374 | %% @private |
| 364 375 | handle_call(Call, _From, State) -> |