Skip to content
This repository was archived by the owner on Nov 17, 2020. It is now read-only.

Commit f79c935

Browse files
committed
Make #amqqueue{} a private record
See the corresponding commit in rabbitmq-server for all the explanations. Now, all accesses to the #amqqueue{} record are made through the `amqqueue` module (available in rabbitmq-server). The new type name is `amqqueue:amqqueue()`. The `amqqueue.hrl` header also provides some macros to help with pattern matching and guard expressions. To help with this, code and modules were moved from rabbitmq-common to rabbitmq-server. [#159298729]
1 parent 8fef32a commit f79c935

File tree

6 files changed

+27
-366
lines changed

6 files changed

+27
-366
lines changed

include/rabbit.hrl

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
%% The Original Code is RabbitMQ.
1212
%%
1313
%% The Initial Developer of the Original Code is Pivotal Software, Inc.
14-
%% Copyright (c) 2007-2017 Pivotal Software, Inc. All rights reserved.
14+
%% Copyright (c) 2007-2018 Pivotal Software, Inc. All rights reserved.
1515
%%
1616

17+
-include("resource.hrl").
18+
1719
%% Passed around most places
1820
-record(user, {username,
1921
tags,
@@ -111,14 +113,6 @@
111113
payload_fragments_rev %% list of binaries, in reverse order (!)
112114
}).
113115

114-
-record(resource, {
115-
virtual_host,
116-
%% exchange, queue, ...
117-
kind,
118-
%% name as a binary
119-
name
120-
}).
121-
122116
%% fields described as 'transient' here are cleared when writing to
123117
%% rabbit_durable_<thing>
124118
-record(exchange, {
@@ -129,24 +123,6 @@
129123
decorators,
130124
options = #{}}). %% transient, recalculated in store/1 (i.e. recovery)
131125

132-
-record(amqqueue, {
133-
name, durable, auto_delete, exclusive_owner = none, %% immutable
134-
arguments, %% immutable
135-
pid, %% durable (just so we know home node)
136-
slave_pids, sync_slave_pids, %% transient
137-
recoverable_slaves, %% durable
138-
policy, %% durable, implicit update as above
139-
operator_policy, %% durable, implicit update as above
140-
gm_pids, %% transient
141-
decorators, %% transient, recalculated as above
142-
state, %% durable (have we crashed?)
143-
policy_version,
144-
slave_pids_pending_shutdown,
145-
vhost, %% secondary index
146-
options = #{},
147-
type = classic,
148-
quorum_nodes }).
149-
150126
-record(exchange_serial, {name, next}).
151127

152128
%% mnesia doesn't like unary records, so we add a dummy 'value' field

include/resource.hrl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
%% The contents of this file are subject to the Mozilla Public License
2+
%% Version 1.1 (the "License"); you may not use this file except in
3+
%% compliance with the License. You may obtain a copy of the License
4+
%% at http://www.mozilla.org/MPL/
5+
%%
6+
%% Software distributed under the License is distributed on an "AS IS"
7+
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
8+
%% the License for the specific language governing rights and
9+
%% limitations under the License.
10+
%%
11+
%% The Original Code is RabbitMQ.
12+
%%
13+
%% The Initial Developer of the Original Code is Pivotal Software, Inc.
14+
%% Copyright (c) 2007-2018 Pivotal Software, Inc. All rights reserved.
15+
%%
16+
17+
-record(resource, {
18+
virtual_host,
19+
%% exchange, queue, ...
20+
kind,
21+
%% name as a binary
22+
name
23+
}).

src/rabbit_backing_queue.erl

Lines changed: 0 additions & 273 deletions
This file was deleted.

src/rabbit_misc.erl

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
-export([method_record_type/1, polite_pause/0, polite_pause/1]).
3030
-export([die/1, frame_error/2, amqp_error/4, quit/1,
3131
protocol_error/3, protocol_error/4, protocol_error/1]).
32-
-export([not_found/1, absent/2]).
3332
-export([type_class/1, assert_args_equivalence/4, assert_field_equivalence/4]).
3433
-export([dirty_read/1]).
3534
-export([table_lookup/2, set_table_value/4]).
@@ -129,9 +128,6 @@
129128
channel_or_connection_exit().
130129
-spec protocol_error(rabbit_types:amqp_error()) ->
131130
channel_or_connection_exit().
132-
-spec not_found(rabbit_types:r(atom())) -> rabbit_types:channel_exit().
133-
-spec absent(rabbit_types:amqqueue(), rabbit_amqqueue:absent_reason()) ->
134-
rabbit_types:channel_exit().
135131
-spec type_class(rabbit_framing:amqp_field_type()) -> atom().
136132
-spec assert_args_equivalence
137133
(rabbit_framing:amqp_table(), rabbit_framing:amqp_table(),
@@ -303,29 +299,6 @@ protocol_error(Name, ExplanationFormat, Params, Method) ->
303299
protocol_error(#amqp_error{} = Error) ->
304300
exit(Error).
305301

306-
not_found(R) -> protocol_error(not_found, "no ~s", [rs(R)]).
307-
308-
absent(#amqqueue{name = QueueName, pid = QPid, durable = true}, nodedown) ->
309-
%% The assertion of durability is mainly there because we mention
310-
%% durability in the error message. That way we will hopefully
311-
%% notice if at some future point our logic changes s.t. we get
312-
%% here with non-durable queues.
313-
protocol_error(not_found,
314-
"home node '~s' of durable ~s is down or inaccessible",
315-
[node(QPid), rs(QueueName)]);
316-
317-
absent(#amqqueue{name = QueueName}, stopped) ->
318-
protocol_error(not_found,
319-
"~s process is stopped by supervisor", [rs(QueueName)]);
320-
321-
absent(#amqqueue{name = QueueName}, crashed) ->
322-
protocol_error(not_found,
323-
"~s has crashed and failed to restart", [rs(QueueName)]);
324-
325-
absent(#amqqueue{name = QueueName}, timeout) ->
326-
protocol_error(not_found,
327-
"failed to perform operation on ~s due to timeout", [rs(QueueName)]).
328-
329302
type_class(byte) -> int;
330303
type_class(short) -> int;
331304
type_class(signedint) -> int;

0 commit comments

Comments
 (0)