-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Emit events on stream consume and cancel
- Loading branch information
1 parent
a8c8cf2
commit 31a4d61
Showing
8 changed files
with
300 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
%% The contents of this file are subject to the Mozilla Public License | ||
%% Version 2.0 (the "License"); you may not use this file except in | ||
%% compliance with the License. You may obtain a copy of the License | ||
%% at https://www.mozilla.org/en-US/MPL/2.0/ | ||
%% | ||
%% Software distributed under the License is distributed on an "AS IS" | ||
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See | ||
%% the License for the specific language governing rights and | ||
%% limitations under the License. | ||
%% | ||
%% The Original Code is RabbitMQ. | ||
%% | ||
%% The Initial Developer of the Original Code is Pivotal Software, Inc. | ||
%% Copyright (c) 2025 Broadcom. All Rights Reserved. | ||
%% The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved. | ||
%% | ||
|
||
-module(rabbit_list_test_event_handler). | ||
|
||
-behaviour(gen_event). | ||
|
||
-export([start_link/0, stop/0, get_events/0, clear_events/0]). | ||
|
||
%% callbacks | ||
-export([init/1, handle_event/2, handle_call/2, handle_info/2, terminate/2, code_change/3]). | ||
|
||
start_link() -> | ||
gen_event:start_link({local, ?MODULE}). | ||
|
||
stop() -> | ||
gen_event:stop(?MODULE). | ||
|
||
get_events() -> | ||
gen_event:call(?MODULE, ?MODULE, get_events). | ||
|
||
clear_events() -> | ||
gen_event:call(?MODULE, ?MODULE, clear_events). | ||
|
||
%% Callbacks | ||
|
||
init([]) -> | ||
{ok, []}. | ||
|
||
handle_event(Event, State) -> | ||
{ok, [Event | State]}. | ||
|
||
handle_call(get_events, State) -> | ||
{ok, lists:reverse(State), State}; | ||
handle_call(clear_events, _) -> | ||
{ok, ok, []}. | ||
|
||
handle_info(_Info, State) -> | ||
{ok, State}. | ||
|
||
terminate(_Reason, _State) -> | ||
ok. | ||
|
||
code_change(_OldVsn, State, _Extra) -> | ||
{ok, State}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.