Skip to content

Remove amqp 0 8 #4997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions deps/rabbit/src/rabbit_framing.erl
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
amqp_method_field_name/0, amqp_property_record/0,
amqp_exception/0, amqp_exception_code/0, amqp_class_id/0]).

-type protocol() :: 'rabbit_framing_amqp_0_8' | 'rabbit_framing_amqp_0_9_1'.
-type protocol() :: 'rabbit_framing_amqp_0_9_1'.

-define(protocol_type(T), type(T :: rabbit_framing_amqp_0_8:T |
rabbit_framing_amqp_0_9_1:T)).
-define(protocol_type(T), type(T :: rabbit_framing_amqp_0_9_1:T)).

-?protocol_type(amqp_field_type()).
-?protocol_type(amqp_property_type()).
Expand Down
15 changes: 2 additions & 13 deletions deps/rabbit/src/rabbit_reader.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1067,17 +1067,6 @@ handshake({0, 0, 9, 1}, State) ->
handshake({1, 1, 0, 9}, State) ->
start_connection({0, 9, 0}, rabbit_framing_amqp_0_9_1, State);

%% This is what most clients send for 0-8. The 0-8 spec, confusingly,
%% defines the version as 8-0.
handshake({1, 1, 8, 0}, State) ->
start_connection({8, 0, 0}, rabbit_framing_amqp_0_8, State);

%% The 0-8 spec as on the AMQP web site actually has this as the
%% protocol header; some libraries e.g., py-amqplib, send it when they
%% want 0-8.
handshake({1, 1, 9, 1}, State) ->
start_connection({8, 0, 0}, rabbit_framing_amqp_0_8, State);

%% ... and finally, the 1.0 spec is crystal clear!
handshake({Id, 1, 0, 0}, State) ->
become_1_0(Id, State);
Expand Down Expand Up @@ -1123,9 +1112,9 @@ ensure_stats_timer(State) ->
%%--------------------------------------------------------------------------

handle_method0(MethodName, FieldsBin,
State = #v1{connection = #connection{protocol = Protocol}}) ->
State = #v1{connection = #connection{}}) ->
try
handle_method0(Protocol:decode_method_fields(MethodName, FieldsBin),
handle_method0(rabbit_framing_amqp_0_9_1:decode_method_fields(MethodName, FieldsBin),
State)
catch throw:{inet_error, E} when E =:= closed; E =:= enotconn ->
maybe_emit_stats(State),
Expand Down
3 changes: 1 addition & 2 deletions deps/rabbit/test/unit_amqp091_content_framing_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ content_transcoding(_Config) ->
sequence_with_content([ClearEncoded, Op]),
sequence_with_content([ClearDecoded, Op])
end || Op <- [ClearDecoded, ClearEncoded, EnsureDecoded,
EnsureEncoded(rabbit_framing_amqp_0_9_1),
EnsureEncoded(rabbit_framing_amqp_0_8)]],
EnsureEncoded(rabbit_framing_amqp_0_9_1)]],
passed.

sequence_with_content(Sequence) ->
Expand Down
3 changes: 0 additions & 3 deletions deps/rabbit_common/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,3 @@
/rabbit_common.d

# Generated source files.
/include/rabbit_framing.hrl
/src/rabbit_framing_amqp_0_8.erl
/src/rabbit_framing_amqp_0_9_1.erl
87 changes: 35 additions & 52 deletions deps/rabbit_common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,49 +12,38 @@ load(
"rabbitmq_suite",
)

py_binary(
name = "codegen",
srcs = [
"codegen.py",
],
imports = ["../../deps/rabbitmq_codegen"],
deps = [
"//deps/rabbitmq_codegen:amqp_codegen",
],
)

genrule(
name = "generated_headers",
srcs = [
"//deps/rabbitmq_codegen:amqp-rabbitmq-0.9.1.json",
"//deps/rabbitmq_codegen:credit_extension.json",
"//deps/rabbitmq_codegen:amqp-rabbitmq-0.8.json",
],
outs = ["include/rabbit_framing.hrl"],
cmd = "$(location :codegen) --ignore-conflicts header $(SRCS) $@",
tools = [":codegen"],
)

genrule(
name = "rabbit_framing_amqp_0_9_1.erl",
srcs = [
"//deps/rabbitmq_codegen:amqp-rabbitmq-0.9.1.json",
"//deps/rabbitmq_codegen:credit_extension.json",
],
outs = ["src/rabbit_framing_amqp_0_9_1.erl"],
cmd = "$(location :codegen) body $(SRCS) $@",
tools = [":codegen"],
)

genrule(
name = "rabbit_framing_amqp_0_8.erl",
srcs = [
"//deps/rabbitmq_codegen:amqp-rabbitmq-0.8.json",
],
outs = ["src/rabbit_framing_amqp_0_8.erl"],
cmd = "$(location :codegen) body $(SRCS) $@",
tools = [":codegen"],
)
# py_binary(
# name = "codegen",
# srcs = [
# "codegen.py",
# ],
# imports = ["../../deps/rabbitmq_codegen"],
# deps = [
# "//deps/rabbitmq_codegen:amqp_codegen",
# ],
# )

# genrule(
# name = "generated_headers",
# srcs = [
# "//deps/rabbitmq_codegen:amqp-rabbitmq-0.9.1.json",
# "//deps/rabbitmq_codegen:credit_extension.json",
# ],
# outs = ["include/rabbit_framing.hrl"],
# cmd = "$(location :codegen) --ignore-conflicts header $(SRCS) $@",
# tools = [":codegen"],
# )

# genrule(
# name = "rabbit_framing_amqp_0_9_1.erl",
# srcs = [
# "//deps/rabbitmq_codegen:amqp-rabbitmq-0.9.1.json",
# "//deps/rabbitmq_codegen:credit_extension.json",
# ],
# outs = ["src/rabbit_framing_amqp_0_9_1.erl"],
# cmd = "$(location :codegen) body $(SRCS) $@",
# tools = [":codegen"],
# )

DEPS = []

Expand Down Expand Up @@ -98,7 +87,7 @@ EXTRA_APPS = [
"xmerl",
]

HDRS = glob(["include/*.hrl"]) + ["include/rabbit_framing.hrl"]
HDRS = glob(["include/*.hrl"])

app_file(
name = "app_file",
Expand All @@ -115,10 +104,7 @@ erlc(
name = "beam_files",
srcs = glob(
["src/*.erl"],
) + [
"src/rabbit_framing_amqp_0_8.erl",
"src/rabbit_framing_amqp_0_9_1.erl",
],
),
hdrs = HDRS,
dest = "ebin",
erlc_opts = RABBITMQ_ERLC_OPTS,
Expand All @@ -142,10 +128,7 @@ erlc(
testonly = True,
srcs = glob(
["src/*.erl"],
) + [
"src/rabbit_framing_amqp_0_8.erl",
"src/rabbit_framing_amqp_0_9_1.erl",
],
),
hdrs = HDRS,
dest = "src",
erlc_opts = RABBITMQ_TEST_ERLC_OPTS,
Expand Down
15 changes: 2 additions & 13 deletions deps/rabbit_common/development.post.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,16 @@ CODEGEN = $(CURDIR)/codegen.py
CODEGEN_DIR ?= $(DEPS_DIR)/rabbitmq_codegen
CODEGEN_AMQP = $(CODEGEN_DIR)/amqp_codegen.py

AMQP_SPEC_JSON_FILES_0_8 = $(CODEGEN_DIR)/amqp-rabbitmq-0.8.json
AMQP_SPEC_JSON_FILES_0_9_1 = $(CODEGEN_DIR)/amqp-rabbitmq-0.9.1.json \
$(CODEGEN_DIR)/credit_extension.json

include/rabbit_framing.hrl:: $(CODEGEN) $(CODEGEN_AMQP) \
$(AMQP_SPEC_JSON_FILES_0_9_1) $(AMQP_SPEC_JSON_FILES_0_8)
$(AMQP_SPEC_JSON_FILES_0_9_1)
$(gen_verbose) env PYTHONPATH=$(CODEGEN_DIR) \
$(PYTHON) $(CODEGEN) --ignore-conflicts header \
$(AMQP_SPEC_JSON_FILES_0_9_1) $(AMQP_SPEC_JSON_FILES_0_8) $@
$(AMQP_SPEC_JSON_FILES_0_9_1) $@

src/rabbit_framing_amqp_0_9_1.erl:: $(CODEGEN) $(CODEGEN_AMQP) \
$(AMQP_SPEC_JSON_FILES_0_9_1)
$(gen_verbose) env PYTHONPATH=$(CODEGEN_DIR) \
$(PYTHON) $(CODEGEN) body $(AMQP_SPEC_JSON_FILES_0_9_1) $@

src/rabbit_framing_amqp_0_8.erl:: $(CODEGEN) $(CODEGEN_AMQP) \
$(AMQP_SPEC_JSON_FILES_0_8)
$(gen_verbose) env PYTHONPATH=$(CODEGEN_DIR) \
$(PYTHON) $(CODEGEN) body $(AMQP_SPEC_JSON_FILES_0_8) $@

clean:: clean-extra-sources

clean-extra-sources:
$(gen_verbose) rm -f $(EXTRA_SOURCES)
14 changes: 10 additions & 4 deletions deps/rabbit_common/development.pre.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@
BUILD_DEPS = rabbitmq_codegen
TEST_DEPS = proper

EXTRA_SOURCES += include/rabbit_framing.hrl \
src/rabbit_framing_amqp_0_8.erl \
src/rabbit_framing_amqp_0_9_1.erl
CODEGEN_SOURCES += include/rabbit_framing.hrl \
src/rabbit_framing_amqp_0_9_1.erl

codegen-clean:
$(gen_verbose) rm -f $(CODEGEN_SOURCES)

codegen: codegen-clean
$(CODEGEN_SOURCES)

.PHONY: codegen codegen-clean

.DEFAULT_GOAL = all
$(PROJECT).d:: $(EXTRA_SOURCES)
113 changes: 113 additions & 0 deletions deps/rabbit_common/include/rabbit_framing.hrl
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
%% Autogenerated code. Do not edit.
%%
%% This Source Code Form is subject to the terms of the Mozilla Public
%% License, v. 2.0. If a copy of the MPL was not distributed with this
%% file, You can obtain one at https://mozilla.org/MPL/2.0/.
%%
%% Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
%%
-define(PROTOCOL_PORT, 5672).
-define(FRAME_METHOD, 1).
-define(FRAME_HEADER, 2).
-define(FRAME_BODY, 3).
-define(FRAME_HEARTBEAT, 8).
-define(FRAME_MIN_SIZE, 4096).
-define(FRAME_END, 206).
-define(REPLY_SUCCESS, 200).
-define(CONTENT_TOO_LARGE, 311).
-define(NO_ROUTE, 312).
-define(NO_CONSUMERS, 313).
-define(ACCESS_REFUSED, 403).
-define(NOT_FOUND, 404).
-define(RESOURCE_LOCKED, 405).
-define(PRECONDITION_FAILED, 406).
-define(CONNECTION_FORCED, 320).
-define(INVALID_PATH, 402).
-define(FRAME_ERROR, 501).
-define(SYNTAX_ERROR, 502).
-define(COMMAND_INVALID, 503).
-define(CHANNEL_ERROR, 504).
-define(UNEXPECTED_FRAME, 505).
-define(RESOURCE_ERROR, 506).
-define(NOT_ALLOWED, 530).
-define(NOT_IMPLEMENTED, 540).
-define(INTERNAL_ERROR, 541).
%% Method field records.
-record('basic.qos', {prefetch_size = 0, prefetch_count = 0, global = false}).
-record('basic.qos_ok', {}).
-record('basic.consume', {ticket = 0, queue = <<"">>, consumer_tag = <<"">>, no_local = false, no_ack = false, exclusive = false, nowait = false, arguments = []}).
-record('basic.consume_ok', {consumer_tag}).
-record('basic.cancel', {consumer_tag, nowait = false}).
-record('basic.cancel_ok', {consumer_tag}).
-record('basic.publish', {ticket = 0, exchange = <<"">>, routing_key = <<"">>, mandatory = false, immediate = false}).
-record('basic.return', {reply_code, reply_text = <<"">>, exchange, routing_key}).
-record('basic.deliver', {consumer_tag, delivery_tag, redelivered = false, exchange, routing_key}).
-record('basic.get', {ticket = 0, queue = <<"">>, no_ack = false}).
-record('basic.get_ok', {delivery_tag, redelivered = false, exchange, routing_key, message_count}).
-record('basic.get_empty', {cluster_id = <<"">>}).
-record('basic.ack', {delivery_tag = 0, multiple = false}).
-record('basic.reject', {delivery_tag, requeue = true}).
-record('basic.recover_async', {requeue = false}).
-record('basic.recover', {requeue = false}).
-record('basic.recover_ok', {}).
-record('basic.nack', {delivery_tag = 0, multiple = false, requeue = true}).
-record('basic.credit', {consumer_tag = <<"">>, credit, drain}).
-record('basic.credit_ok', {available}).
-record('basic.credit_drained', {consumer_tag = <<"">>, credit_drained}).
-record('connection.start', {version_major = 0, version_minor = 9, server_properties, mechanisms = <<"PLAIN">>, locales = <<"en_US">>}).
-record('connection.start_ok', {client_properties, mechanism = <<"PLAIN">>, response, locale = <<"en_US">>}).
-record('connection.secure', {challenge}).
-record('connection.secure_ok', {response}).
-record('connection.tune', {channel_max = 0, frame_max = 0, heartbeat = 0}).
-record('connection.tune_ok', {channel_max = 0, frame_max = 0, heartbeat = 0}).
-record('connection.open', {virtual_host = <<"/">>, capabilities = <<"">>, insist = false}).
-record('connection.open_ok', {known_hosts = <<"">>}).
-record('connection.close', {reply_code, reply_text = <<"">>, class_id, method_id}).
-record('connection.close_ok', {}).
-record('connection.blocked', {reason = <<"">>}).
-record('connection.unblocked', {}).
-record('connection.update_secret', {new_secret, reason}).
-record('connection.update_secret_ok', {}).
-record('channel.open', {out_of_band = <<"">>}).
-record('channel.open_ok', {channel_id = <<"">>}).
-record('channel.flow', {active}).
-record('channel.flow_ok', {active}).
-record('channel.close', {reply_code, reply_text = <<"">>, class_id, method_id}).
-record('channel.close_ok', {}).
-record('access.request', {realm = <<"/data">>, exclusive = false, passive = true, active = true, write = true, read = true}).
-record('access.request_ok', {ticket = 1}).
-record('exchange.declare', {ticket = 0, exchange, type = <<"direct">>, passive = false, durable = false, auto_delete = false, internal = false, nowait = false, arguments = []}).
-record('exchange.declare_ok', {}).
-record('exchange.delete', {ticket = 0, exchange, if_unused = false, nowait = false}).
-record('exchange.delete_ok', {}).
-record('exchange.bind', {ticket = 0, destination, source, routing_key = <<"">>, nowait = false, arguments = []}).
-record('exchange.bind_ok', {}).
-record('exchange.unbind', {ticket = 0, destination, source, routing_key = <<"">>, nowait = false, arguments = []}).
-record('exchange.unbind_ok', {}).
-record('queue.declare', {ticket = 0, queue = <<"">>, passive = false, durable = false, exclusive = false, auto_delete = false, nowait = false, arguments = []}).
-record('queue.declare_ok', {queue, message_count, consumer_count}).
-record('queue.bind', {ticket = 0, queue = <<"">>, exchange, routing_key = <<"">>, nowait = false, arguments = []}).
-record('queue.bind_ok', {}).
-record('queue.purge', {ticket = 0, queue = <<"">>, nowait = false}).
-record('queue.purge_ok', {message_count}).
-record('queue.delete', {ticket = 0, queue = <<"">>, if_unused = false, if_empty = false, nowait = false}).
-record('queue.delete_ok', {message_count}).
-record('queue.unbind', {ticket = 0, queue = <<"">>, exchange, routing_key = <<"">>, arguments = []}).
-record('queue.unbind_ok', {}).
-record('tx.select', {}).
-record('tx.select_ok', {}).
-record('tx.commit', {}).
-record('tx.commit_ok', {}).
-record('tx.rollback', {}).
-record('tx.rollback_ok', {}).
-record('confirm.select', {nowait = false}).
-record('confirm.select_ok', {}).
%% Class property records.
-record('P_basic', {content_type, content_encoding, headers, delivery_mode, priority, correlation_id, reply_to, expiration, message_id, timestamp, type, user_id, app_id, cluster_id}).
-record('P_connection', {}).
-record('P_channel', {}).
-record('P_access', {}).
-record('P_exchange', {}).
-record('P_queue', {}).
-record('P_tx', {}).
-record('P_confirm', {}).
Loading