Skip to content
Browse files

WHISTLE-42: holy hell of an update for the build process

  • Loading branch information...
1 parent 7f8df3e commit 6491be12181c12dbe03f49a16d4e12c6db74f970 @jamesaimonetti jamesaimonetti committed Sep 13, 2012
Showing with 197 additions and 27,655 deletions.
  1. +3 −0 .gitignore
  2. +24 −12 Makefile
  3. +2 −2 ecallmgr/Makefile
  4. +19 −0 lib/Makefile
  5. +0 −26 lib/amqp_client-2.8.1/Makefile
  6. +0 −157 lib/amqp_client-2.8.1/README
  7. +0 −200 lib/amqp_client-2.8.1/common.mk
  8. +0 −22 lib/amqp_client-2.8.1/deps.mk
  9. 0 lib/amqp_client-2.8.1/deps/rabbit_common-2.8.1/ebin/.placeholder
  10. +0 −101 lib/amqp_client-2.8.1/deps/rabbit_common-2.8.1/include/rabbit.hrl
  11. +0 −31 lib/amqp_client-2.8.1/deps/rabbit_common-2.8.1/include/rabbit_auth_backend_spec.hrl
  12. +0 −28 lib/amqp_client-2.8.1/deps/rabbit_common-2.8.1/include/rabbit_auth_mechanism_spec.hrl
  13. +0 −70 lib/amqp_client-2.8.1/deps/rabbit_common-2.8.1/include/rabbit_backing_queue_spec.hrl
  14. +0 −38 lib/amqp_client-2.8.1/deps/rabbit_common-2.8.1/include/rabbit_exchange_type_spec.hrl
  15. +0 −45 lib/amqp_client-2.8.1/deps/rabbit_common-2.8.1/include/rabbit_msg_store_index.hrl
  16. 0 lib/amqp_client-2.8.1/deps/rabbit_common-2.8.1/src/.placeholder
  17. 0 lib/amqp_client-2.8.1/ebin/.ignore
  18. 0 lib/amqp_client-2.8.1/ebin/.placeholder
  19. +0 −74 lib/amqp_client-2.8.1/include/amqp_client.hrl
  20. +0 −873 lib/amqp_client-2.8.1/src/amqp_channel.erl
  21. +0 −79 lib/amqp_client-2.8.1/src/amqp_channel_sup.erl
  22. +0 −255 lib/amqp_client-2.8.1/src/amqp_channels_manager.erl
  23. +0 −16 lib/amqp_client-2.8.1/src/amqp_client.app.src
  24. +0 −286 lib/amqp_client-2.8.1/src/amqp_connection.erl
  25. +0 −65 lib/amqp_client-2.8.1/src/amqp_connection_type_sup.erl
  26. +0 −148 lib/amqp_client-2.8.1/src/amqp_direct_connection.erl
  27. +0 −345 lib/amqp_client-2.8.1/src/amqp_gen_connection.erl
  28. +0 −252 lib/amqp_client-2.8.1/src/amqp_gen_consumer.erl
  29. +0 −106 lib/amqp_client-2.8.1/src/amqp_main_reader.erl
  30. +0 −298 lib/amqp_client-2.8.1/src/amqp_network_connection.erl
  31. +0 −171 lib/amqp_client-2.8.1/src/amqp_rpc_client.erl
  32. +0 −133 lib/amqp_client-2.8.1/src/amqp_rpc_server.erl
  33. +0 −198 lib/amqp_client-2.8.1/src/amqp_uri.erl
  34. +0 −121 lib/amqp_client-2.8.1/test/amqp_client_SUITE.erl
  35. +0 −195 lib/amqp_client-2.8.1/test/negative_test_util.erl
  36. +0 −994 lib/amqp_client-2.8.1/test/test_util.erl
  37. +10 −7 lib/basho-lager_syslog/Makefile
  38. +3 −1 lib/braintree-1.0.0/Makefile
  39. +8 −6 lib/couchbeam-0.8.0/Makefile
  40. +3 −1 lib/cowboy-0.5.1/Makefile
  41. +5 −2 lib/detergent-0.2/Makefile
  42. +6 −4 lib/ecsv-1/Makefile
  43. +9 −3 lib/ejson-0.1.0/Makefile
  44. +14 −7 lib/erl_openid/Makefile
  45. +1 −2 lib/erl_openid/rebar.config
  46. +1 −1 lib/erl_openid/src/openid_http.erl
  47. +1 −1 lib/erl_openid/src/openid_utils.erl
  48. +12 −2 lib/erlang-localtime-1.0/Makefile
  49. +5 −2 lib/erlsom-1.3/Makefile
  50. +4 −3 lib/erlydtl-0.7.0/Makefile
  51. +7 −2 lib/gen_smtp-0.1/Makefile
  52. +7 −5 lib/gproc-0.2.12/Makefile
  53. +5 −2 lib/gproc-0.2.12/deps/edown/Makefile
  54. +7 −0 lib/gproc-0.2.12/deps/edown/ebin/edown.app
  55. +11 −4 lib/ibrowse-4.0.0/Makefile
  56. +3 −1 lib/kazoo_translator-1.0.0/Makefile
  57. +10 −7 lib/lager-1.0.0/Makefile
  58. +8 −5 lib/mochiweb-2.3.1/Makefile
  59. +6 −2 lib/oauth-1.2.2/Makefile
  60. +3 −1 lib/poolboy-0.6.1/Makefile
  61. +0 −5 lib/pqueue-0.1.9/Makefile
  62. +0 −31 lib/pqueue-0.1.9/README.markdown
  63. 0 lib/pqueue-0.1.9/ebin/.placeholder
  64. +0 −2 lib/pqueue-0.1.9/rebar.config
  65. +0 −2 lib/pqueue-0.1.9/src/Makefile
  66. +0 −7 lib/pqueue-0.1.9/src/pqueue.app.src
  67. +0 −2,210 lib/pqueue-0.1.9/src/pqueue.erl
  68. +0 −473 lib/pqueue-0.1.9/src/pqueue2.erl
  69. +0 −417 lib/pqueue-0.1.9/src/pqueue3.erl
  70. +0 −9,165 lib/pqueue-0.1.9/src/pqueue4.erl
  71. +0 −156 lib/pqueue-0.1.9/src/pqueue_proper.erl
  72. +0 −185 lib/pqueue-0.1.9/src/queue_srv.erl
  73. +0 −674 lib/proper-1.0/COPYING
  74. +0 −59 lib/proper-1.0/Makefile
  75. +0 −1,245 lib/proper-1.0/README
  76. +0 −142 lib/proper-1.0/README.md
  77. +0 −36 lib/proper-1.0/check_escripts.sh
  78. +0 −25 lib/proper-1.0/clean_doc.sh
  79. +0 −25 lib/proper-1.0/clean_temp.sh
  80. +0 −50 lib/proper-1.0/doc/overview.edoc
  81. +0 −38 lib/proper-1.0/examples/b64.erl
  82. +0 −249 lib/proper-1.0/examples/elevator_fsm.erl
  83. +0 −238 lib/proper-1.0/examples/ets_statem.erl
  84. +0 −688 lib/proper-1.0/examples/mm.erl
  85. +0 −102 lib/proper-1.0/examples/pdict_statem.erl
  86. +0 −78 lib/proper-1.0/examples/stack.erl
  87. +0 −1 lib/proper-1.0/include/compile_flags.hrl
  88. +0 −103 lib/proper-1.0/include/proper.hrl
  89. +0 −55 lib/proper-1.0/include/proper_common.hrl
  90. +0 −79 lib/proper-1.0/include/proper_internal.hrl
  91. +0 −41 lib/proper-1.0/include/proper_param_adts.hrl
  92. +0 −379 lib/proper-1.0/make_doc
  93. +0 −38 lib/proper-1.0/rebar.config
  94. +0 −30 lib/proper-1.0/src/proper.app.src
  95. +0 −1,878 lib/proper-1.0/src/proper.erl
  96. +0 −317 lib/proper-1.0/src/proper_arith.erl
  97. +0 −173 lib/proper-1.0/src/proper_array.erl
  98. +0 −152 lib/proper-1.0/src/proper_dict.erl
  99. +0 −404 lib/proper-1.0/src/proper_fsm.erl
  100. +0 −222 lib/proper-1.0/src/proper_funserver.erl
  101. +0 −188 lib/proper-1.0/src/proper_gb_sets.erl
  102. +0 −141 lib/proper-1.0/src/proper_gb_trees.erl
  103. +0 −584 lib/proper-1.0/src/proper_gen.erl
  104. +0 −125 lib/proper-1.0/src/proper_orddict.erl
  105. +0 −116 lib/proper-1.0/src/proper_ordsets.erl
  106. +0 −126 lib/proper-1.0/src/proper_prop_remover.erl
  107. +0 −167 lib/proper-1.0/src/proper_queue.erl
  108. +0 −116 lib/proper-1.0/src/proper_sets.erl
  109. +0 −506 lib/proper-1.0/src/proper_shrink.erl
Sorry, we could not display the entire diff because too many files (1,106) changed.
View
3 .gitignore
@@ -8,6 +8,9 @@ lib/*/ebin/*.app
lib/*/priv/*.so
lib/*/c_src/*.o
lib/*/c_src/*/*.o
+lib/*/deps/*/ebin/*.beam
+lib/*/deps/*/ebin/*.app
+lib/*/dist/*
*/deps/*/ebin/*.beam
*/ebin/*.app
*/priv/*.pid
View
36 Makefile
@@ -2,31 +2,43 @@ ROOT = .
DIALYZER = dialyzer
REBAR = $(ROOT)/bin/rebar
-DIRS = lib/whistle-1.0.0 lib/whistle_couch-1.0.0 lib/whistle_amqp-1.0.0 lib/whistle_number_manager-1.0.0 ecallmgr whistle_apps
+MAKEDIRS = */Makefile
-all: app
+DIRS = $(ROOT)/lib/whistle-1.0.0 \
+ $(ROOT)/lib/whistle_couch-1.0.0 \
+ $(ROOT)/lib/whistle_amqp-1.0.0 \
+ $(ROOT)/lib/whistle_number_manager-1.0.0 \
+ $(ROOT)/ecallmgr \
+ $(ROOT)/whistle_apps
-app:
- @$(REBAR) compile
+.PHONY: $(MAKEDIRS)
-deps:
- @$(REBAR) get-deps
+all : compile
-clean:
- @$(REBAR) clean
+compile: ACTION = all
+compile: $(MAKEDIRS)
+
+$(MAKEDIRS):
+ $(MAKE) -C $(@D) $(ACTION)
+
+deps : ACTION = get-deps
+deps : $(MAKEDIRS)
+
+clean : ACTION = clean
+clean : $(MAKEDIRS)
rm -f test/*.beam
rm -f erl_crash.dump
-test: clean app eunit
+test : clean app eunit
-eunit:
+eunit :
@$(REBAR) eunit skip_deps=true
-build-plt:
+build-plt :
@$(DIALYZER) --build_plt --output_plt $(ROOT)/.platform_dialyzer.plt \
--apps erts kernel stdlib sasl inets crypto public_key ssl
-dialyze:
+dialyze :
@$(DIALYZER) $(foreach DIR,$(DIRS),$(DIR)/ebin) \
--plt $(ROOT)/.platform_dialyzer.plt --no_native \
-Werror_handling -Wrace_conditions -Wunmatched_returns # -Wunderspecs
View
4 ecallmgr/Makefile
@@ -4,9 +4,9 @@ REBAR = $(ROOT)/bin/rebar
DIRS = . $(ROOT)/lib/whistle-1.0.0 $(ROOT)/lib/whistle_amqp-1.0.0
-all: app
+all: compile
-app:
+compile:
@$(REBAR) compile
deps:
View
19 lib/Makefile
@@ -0,0 +1,19 @@
+ROOT = ..
+REBAR = $(ROOT)/bin/rebar
+
+MAKEDIRS = */Makefile
+
+.PHONY: all compile clean $(MAKEDIRS)
+
+all: compile
+
+compile: ACTION = all
+compile: $(MAKEDIRS)
+ $(REBAR) compile
+
+clean: ACTION = clean
+clean: $(MAKEDIRS)
+ $(REBAR) clean
+
+$(MAKEDIRS):
+ $(MAKE) -C $(@D) $(ACTION)
View
26 lib/amqp_client-2.8.1/Makefile
@@ -1,26 +0,0 @@
-# The contents of this file are subject to the Mozilla Public License
-# Version 1.1 (the "License"); you may not use this file except in
-# compliance with the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# 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 VMware, Inc.
-# Copyright (c) 2007-2012 VMware, Inc. All rights reserved.
-#
-
-VERSION=2.8.1
-
-include common.mk
-include test.mk
-
-clean: common_clean
-
-compile_tests:
- $(MAKE) -C test VERSION=$(VERSION)
-
View
157 lib/amqp_client-2.8.1/README
@@ -1,157 +0,0 @@
-README.in:
-
-Please see http://www.rabbitmq.com/build-erlang-client.html for build
-instructions.
-
-For your convenience, a text copy of these instructions is available
-below. Please be aware that the instructions here may not be as up to
-date as those at the above URL.
-
-===========================================================================
-
-
- RabbitMQ
- SpringSource
- __________________________ [ ]
-
- * Installation
- * Documentation
- * Tutorials
- * Services
- * Community
- * Blog
-
- Erlang AMQP Client Library Build Instructions
-
- This section describes the process for obtaining a copy of the RabbitMQ
- Erlang AMQP client source code and its dependecies, as well as
- instructions for building the Erlang client from source.
-
-Obtaining the source
-
- * Either download a released source code distribution from the download
- page, or
- * Check the code out directly from our mercurial repositories:
-
- $ hg clone http://hg.rabbitmq.com/rabbitmq-codegen
- $ hg clone http://hg.rabbitmq.com/rabbitmq-server
- $ hg clone http://hg.rabbitmq.com/rabbitmq-erlang-client
- $ cd rabbitmq-erlang-client
- $ make
-
- If you choose to check the code out using mercurial, be aware that the
- server code and the code-generation module are dependencies of the Erlang
- client library. If you're working with a released source code
- distribution, though, all necessary dependecies are included.
-
-Required Libraries and Tools
-
- In order to build RabbitMQ, you will need a few tools.
-
- RabbitMQ requires a recent version of Python and simplejson.py (an
- implementation of a JSON reader and writer in Python), for generating AMQP
- framing code. simplejson.py is included as a standard json library in the
- Python core since 2.6 release.
-
- Additionally, you will need
-
- * the Erlang development and runtime tools
- If you are on a Debian-based system then you need the erlang-nox and
- erlang-dev packages installed. If you are building and installing
- Erlang from source then you must ensure that openssl is installed on
- your system.
- * a recent version of GNU make
- * a recent version of xsltproc, which is part of libxslt
-
-Building the Erlang client libraries
-
- You will need to get the source of the server and the codegen. If you ran
- the commands above, the these will be placed in sibling directories to the
- Erlang client (i.e: ../rabbitmq-server and ../rabbitmq-codegen), which is
- the default that the Makefile expects. In this case, you can just run
- make.
-
- If the source tree for the server is not in the sibling directory, you
- will need to specify the path to this directory with make
- BROKER_DIR=/path/to/server. In this case, make sure you specify BROKER_DIR
- every time you run a make target.
-
- Other interesting Makefile targets include
-
- all
- The default target. Builds the client libraries.
-
- run
- Builds the client libraries and starts an Erlang shell with the
- libraries loaded.
-
- run_in_broker
- Builds the client and starts RabbitMQ server with shell and the
- client included in load path.
-
- clean
- Removes build products.
-
- test
- Runs a set of tests against a server running on locally. You will
- need to start a local instance of an AMQP server, running on port
- 5672, which allows guest/guest access on virtual host "/",
- beforehand.
-
- all_tests
- Clean compiles the client and client tests source code and runs
- network_client_SUITE, direct_client_SUITE and packaging tests.
- During testing, this make target runs an instance of the broker,
- so make sure there is no other instance of RabbitMQ server
- running.
-
- dialyze
- Analyses the client source code with dialyzer. Uses PLT file from
- default location: ~/.dialyzer_plt. Use
-
- $ make PLT=/path/to/plt dialyze
-
- to override this. Add broker to PLT beforehand, otherwise you will
- a lot of 'unknown function' warnings. See add_broker_to_plt make
- target.
-
- dialyze_all
- Same as dialyze, except that this also analyses tests source code.
-
- add_broker_to_plt
- Adds broker .beam files to default plt. Use
-
- $ make PLT=/path/to/plt add_broker_to_plt
-
- to override default plt location (~/.dialyzer_plt).
-
- source_tarball
- Creates tarball of all the client source code.
-
- package
- Creates an erlang archive of the client.
-
- common_package
- Creates an erlang archive of the server modules required by the
- erlang client.
-
- In This Section
-
- * Server Documentation
- * Client Documentation
- * Plugins
- * News
- * Protocol
- * Building
-
- * Building the Server
- * Building the Java Client
- * Building the .NET Client
- * Building the Erlang Client
- * Our use of Mercurial
-
- * License
-
- Sitemap | Contact
-
- Copyright © 2012 VMware, Inc. All rights reserved. Terms of Use | Privacy
View
200 lib/amqp_client-2.8.1/common.mk
@@ -1,200 +0,0 @@
-# The contents of this file are subject to the Mozilla Public License
-# Version 1.1 (the "License"); you may not use this file except in
-# compliance with the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# 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 VMware, Inc.
-# Copyright (c) 2007-2012 VMware, Inc. All rights reserved.
-#
-
-# The client library can either be built from source control or by downloading
-# a source tarball from the RabbitMQ site. The intention behind the source tarball is
-# to be able to unpack this anywhere and just run a simple a test, under the
-# assumption that you have a running broker. This provides the simplest
-# possible way of building and running the client.
-#
-# The source control version, on the other hand, contains far more infrastructure
-# to start and stop brokers, package modules from the server, run embedded tests
-# and so forth.
-#
-# This means that the Makefile of the source control version contains a lot of
-# functionality that just wouldn't work with the source tarball version.
-#
-# The purpose of this common Makefile is to define as many commonalities
-# between the build requirements of the source control version and the source
-# tarball version. This avoids duplicating make definitions and rules and
-# helps keep the Makefile maintenence well factored.
-
-ifndef TMPDIR
-TMPDIR := /tmp
-endif
-
-EBIN_DIR=ebin
-BROKER_DIR=../rabbitmq-server
-export INCLUDE_DIR=include
-TEST_DIR=test
-SOURCE_DIR=src
-DIST_DIR=dist
-DEPS_DIR=deps
-DOC_DIR=doc
-DEPS_FILE=deps.mk
-
-ifeq ("$(ERL_LIBS)", "")
- ERL_LIBS :=
-else
- ERL_LIBS := :$(ERL_LIBS)
-endif
-
-ERL_PATH ?=
-
-PACKAGE=amqp_client
-PACKAGE_DIR=$(PACKAGE)-$(VERSION)
-PACKAGE_NAME_EZ=$(PACKAGE_DIR).ez
-COMMON_PACKAGE=rabbit_common
-export COMMON_PACKAGE_DIR=$(COMMON_PACKAGE)-$(VERSION)
-COMMON_PACKAGE_EZ=$(COMMON_PACKAGE_DIR).ez
-
-DEPS=$(shell erl -noshell -eval '{ok,[{_,_,[_,_,{modules, Mods},_,_,_]}]} = \
- file:consult("$(COMMON_PACKAGE).app.in"), \
- [io:format("~p ",[M]) || M <- Mods], halt().')
-
-INCLUDES=$(wildcard $(INCLUDE_DIR)/*.hrl)
-SOURCES=$(wildcard $(SOURCE_DIR)/*.erl)
-TARGETS=$(patsubst $(SOURCE_DIR)/%.erl, $(EBIN_DIR)/%.beam, $(SOURCES))
-TEST_SOURCES=$(wildcard $(TEST_DIR)/*.erl)
-TEST_TARGETS=$(patsubst $(TEST_DIR)/%.erl, $(TEST_DIR)/%.beam, $(TEST_SOURCES))
-
-LIBS_PATH_UNIX=$(DEPS_DIR):$(DIST_DIR)$(ERL_LIBS)
-IS_CYGWIN=$(shell if [ $(shell expr "$(shell uname -s)" : 'CYGWIN_NT') -gt 0 ]; then echo "true"; else echo "false"; fi)
-ifeq ($(IS_CYGWIN),true)
- LIBS_PATH=ERL_LIBS="$(shell cygpath -wp $(LIBS_PATH_UNIX))"
-else
- LIBS_PATH=ERL_LIBS=$(LIBS_PATH_UNIX)
-endif
-
-LOAD_PATH=$(EBIN_DIR) $(TEST_DIR) $(ERL_PATH)
-
-RUN:=$(LIBS_PATH) erl -pa $(LOAD_PATH) -sname amqp_client
-
-MKTEMP=$$(mktemp $(TMPDIR)/tmp.XXXXXXXXXX)
-
-ifndef USE_SPECS
-# our type specs rely on features / bug fixes in dialyzer that are
-# only available in R13B01 upwards (R13B is eshell 5.7.2)
-#
-# NB: do not mark this variable for export, otherwise it will
-# override the test in rabbitmq-server's Makefile when it does the
-# make -C, which causes problems whenever the test here and the test
-# there compare system_info(version) against *different* eshell
-# version numbers.
-USE_SPECS:=$(shell erl -noshell -eval 'io:format([list_to_integer(X) || X <- string:tokens(erlang:system_info(version), ".")] >= [5,7,2]), halt().')
-endif
-
-ERLC_OPTS=-I $(INCLUDE_DIR) -pa $(EBIN_DIR) -o $(EBIN_DIR) -Wall -v +debug_info $(if $(filter true,$(USE_SPECS)),-Duse_specs)
-
-RABBITMQ_NODENAME=rabbit
-PA_LOAD_PATH=-pa $(realpath $(LOAD_PATH))
-RABBITMQCTL=$(BROKER_DIR)/scripts/rabbitmqctl
-
-ifdef SSL_CERTS_DIR
-SSL := true
-ALL_SSL := { $(MAKE) test_ssl || OK=false; }
-ALL_SSL_COVERAGE := { $(MAKE) test_ssl_coverage || OK=false; }
-SSL_BROKER_ARGS := -rabbit ssl_listeners [{\\\"0.0.0.0\\\",5671},{\\\"::1\\\",5671}] \
- -rabbit ssl_options [{cacertfile,\\\"$(SSL_CERTS_DIR)/testca/cacert.pem\\\"},{certfile,\\\"$(SSL_CERTS_DIR)/server/cert.pem\\\"},{keyfile,\\\"$(SSL_CERTS_DIR)/server/key.pem\\\"},{verify,verify_peer},{fail_if_no_peer_cert,true}]
-SSL_CLIENT_ARGS := -erlang_client_ssl_dir $(SSL_CERTS_DIR)
-else
-SSL := @echo No SSL_CERTS_DIR defined. && false
-ALL_SSL := true
-ALL_SSL_COVERAGE := true
-SSL_BROKER_ARGS :=
-SSL_CLIENT_ARGS :=
-endif
-
-# Versions prior to this are not supported
-NEED_MAKE := 3.80
-ifneq "$(NEED_MAKE)" "$(firstword $(sort $(NEED_MAKE) $(MAKE_VERSION)))"
-$(error Versions of make prior to $(NEED_MAKE) are not supported)
-endif
-
-# .DEFAULT_GOAL introduced in 3.81
-DEFAULT_GOAL_MAKE := 3.81
-ifneq "$(DEFAULT_GOAL_MAKE)" "$(firstword $(sort $(DEFAULT_GOAL_MAKE) $(MAKE_VERSION)))"
-.DEFAULT_GOAL=all
-endif
-
-all: package
-
-common_clean:
- rm -f $(EBIN_DIR)/*.beam
- rm -f erl_crash.dump
- rm -rf $(DEPS_DIR)
- rm -rf $(DOC_DIR)
- rm -f $(DEPS_FILE)
- $(MAKE) -C $(TEST_DIR) clean
-
-compile: $(TARGETS) $(EBIN_DIR)/$(PACKAGE).app
-
-run: compile
- $(RUN)
-
-###############################################################################
-## Packaging
-###############################################################################
-
-$(DIST_DIR)/$(PACKAGE_NAME_EZ): $(TARGETS) $(EBIN_DIR)/$(PACKAGE).app | $(DIST_DIR)
- rm -f $@
- rm -rf $(DIST_DIR)/$(PACKAGE_DIR)
- mkdir -p $(DIST_DIR)/$(PACKAGE_DIR)/$(EBIN_DIR)
- mkdir -p $(DIST_DIR)/$(PACKAGE_DIR)/$(INCLUDE_DIR)
- cp -r $(EBIN_DIR)/*.beam $(DIST_DIR)/$(PACKAGE_DIR)/$(EBIN_DIR)
- cp -r $(EBIN_DIR)/*.app $(DIST_DIR)/$(PACKAGE_DIR)/$(EBIN_DIR)
- mkdir -p $(DIST_DIR)/$(PACKAGE_DIR)/$(INCLUDE_DIR)
- cp -r $(INCLUDE_DIR)/* $(DIST_DIR)/$(PACKAGE_DIR)/$(INCLUDE_DIR)
- (cd $(DIST_DIR); zip -q -r $(PACKAGE_NAME_EZ) $(PACKAGE_DIR))
-
-package: $(DIST_DIR)/$(PACKAGE_NAME_EZ)
-
-###############################################################################
-## Internal targets
-###############################################################################
-
-$(DEPS_DIR)/$(COMMON_PACKAGE_DIR): $(DIST_DIR)/$(COMMON_PACKAGE_EZ) | $(DEPS_DIR)
- rm -rf $(DEPS_DIR)/$(COMMON_PACKAGE_DIR)
- mkdir -p $(DEPS_DIR)/$(COMMON_PACKAGE_DIR)
- unzip -q -o $< -d $(DEPS_DIR)
-
-$(DEPS_FILE): $(SOURCES) $(INCLUDES)
- rm -f $@
- echo $(subst : ,:,$(foreach FILE,$^,$(FILE):)) | escript $(BROKER_DIR)/generate_deps $@ $(EBIN_DIR)
-
-$(EBIN_DIR)/%.beam: $(SOURCE_DIR)/%.erl $(INCLUDES) $(DEPS_DIR)/$(COMMON_PACKAGE_DIR) | $(DEPS_FILE)
- $(LIBS_PATH) erlc $(ERLC_OPTS) $<
-
-$(DEPS_DIR):
- mkdir -p $@
-
-# Note that all targets which depend on clean must have clean in their
-# name. Also any target that doesn't depend on clean should not have
-# clean in its name, unless you know that you don't need any of the
-# automatic dependency generation for that target.
-
-# We want to load the dep file if *any* target *doesn't* contain
-# "clean" - i.e. if removing all clean-like targets leaves something
-
-ifeq "$(MAKECMDGOALS)" ""
-TESTABLEGOALS:=$(.DEFAULT_GOAL)
-else
-TESTABLEGOALS:=$(MAKECMDGOALS)
-endif
-
-ifneq "$(strip $(patsubst clean%,,$(patsubst %clean,,$(TESTABLEGOALS))))" ""
--include $(DEPS_FILE)
-endif
View
22 lib/amqp_client-2.8.1/deps.mk
@@ -1,22 +0,0 @@
-ebin/amqp_gen_consumer.beam: src/amqp_gen_consumer.erl include/amqp_client.hrl
-ebin/amqp_connection.beam: src/amqp_connection.erl include/amqp_client.hrl
-ebin/amqp_connection_type_sup.beam: src/amqp_connection_type_sup.erl include/amqp_client.hrl
-ebin/amqp_sup.beam: src/amqp_sup.erl include/amqp_client.hrl
-ebin/amqp_uri.beam: src/amqp_uri.erl include/amqp_client.hrl
-ebin/amqp_rpc_client.beam: src/amqp_rpc_client.erl include/amqp_client.hrl
-ebin/amqp_auth_mechanisms.beam: src/amqp_auth_mechanisms.erl include/amqp_client.hrl
-ebin/amqp_network_connection.beam: src/amqp_network_connection.erl ebin/amqp_gen_connection.beam include/amqp_client.hrl
-ebin/amqp_channel_sup_sup.beam: src/amqp_channel_sup_sup.erl include/amqp_client.hrl
-ebin/amqp_main_reader.beam: src/amqp_main_reader.erl include/amqp_client.hrl
-ebin/amqp_selective_consumer.beam: src/amqp_selective_consumer.erl include/amqp_client.hrl include/amqp_gen_consumer_spec.hrl ebin/amqp_gen_consumer.beam
-ebin/amqp_direct_connection.beam: src/amqp_direct_connection.erl ebin/amqp_gen_connection.beam include/amqp_client.hrl
-ebin/amqp_channel_sup.beam: src/amqp_channel_sup.erl include/amqp_client.hrl
-ebin/amqp_rpc_server.beam: src/amqp_rpc_server.erl include/amqp_client.hrl
-ebin/amqp_channels_manager.beam: src/amqp_channels_manager.erl include/amqp_client.hrl
-ebin/amqp_direct_consumer.beam: src/amqp_direct_consumer.erl include/amqp_client.hrl include/amqp_gen_consumer_spec.hrl ebin/amqp_gen_consumer.beam
-ebin/uri_parser.beam: src/uri_parser.erl
-ebin/amqp_channel.beam: src/amqp_channel.erl include/amqp_client.hrl
-ebin/amqp_gen_connection.beam: src/amqp_gen_connection.erl include/amqp_client.hrl
-ebin/amqp_client.beam: src/amqp_client.erl
-ebin/amqp_connection_sup.beam: src/amqp_connection_sup.erl include/amqp_client.hrl
-deps.mk: ../rabbitmq-server/generate_deps
View
0 lib/amqp_client-2.8.1/deps/rabbit_common-2.8.1/ebin/.placeholder
No changes.
View
0 lib/amqp_client-2.8.1/deps/rabbit_common-2.8.1/include/gm_specs.hrl
Sorry, we could not display the changes to this file because there were too many other changes to display.
View
101 lib/amqp_client-2.8.1/deps/rabbit_common-2.8.1/include/rabbit.hrl
@@ -1,101 +0,0 @@
-%% The contents of this file are subject to the Mozilla Public License
-%% Version 1.1 (the "License"); you may not use this file except in
-%% compliance with the License. You may obtain a copy of the License
-%% at http://www.mozilla.org/MPL/
-%%
-%% 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 VMware, Inc.
-%% Copyright (c) 2007-2012 VMware, Inc. All rights reserved.
-%%
-
--record(user, {username,
- tags,
- auth_backend, %% Module this user came from
- impl %% Scratch space for that module
- }).
-
--record(internal_user, {username, password_hash, tags}).
--record(permission, {configure, write, read}).
--record(user_vhost, {username, virtual_host}).
--record(user_permission, {user_vhost, permission}).
-
--record(vhost, {virtual_host, dummy}).
-
--record(connection, {protocol, user, timeout_sec, frame_max, vhost,
- client_properties, capabilities}).
-
--record(content,
- {class_id,
- properties, %% either 'none', or a decoded record/tuple
- properties_bin, %% either 'none', or an encoded properties binary
- %% Note: at most one of properties and properties_bin can be
- %% 'none' at once.
- protocol, %% The protocol under which properties_bin was encoded
- payload_fragments_rev %% list of binaries, in reverse order (!)
- }).
-
--record(resource, {virtual_host, kind, name}).
-
--record(exchange, {name, type, durable, auto_delete, internal, arguments,
- scratch}).
--record(exchange_serial, {name, next}).
-
--record(amqqueue, {name, durable, auto_delete, exclusive_owner = none,
- arguments, pid, slave_pids, mirror_nodes}).
-
-%% mnesia doesn't like unary records, so we add a dummy 'value' field
--record(route, {binding, value = const}).
--record(reverse_route, {reverse_binding, value = const}).
-
--record(binding, {source, key, destination, args = []}).
--record(reverse_binding, {destination, key, source, args = []}).
-
--record(topic_trie_node, {trie_node, edge_count, binding_count}).
--record(topic_trie_edge, {trie_edge, node_id}).
--record(topic_trie_binding, {trie_binding, value = const}).
-
--record(trie_node, {exchange_name, node_id}).
--record(trie_edge, {exchange_name, node_id, word}).
--record(trie_binding, {exchange_name, node_id, destination}).
-
--record(listener, {node, protocol, host, ip_address, port}).
-
--record(basic_message, {exchange_name, routing_keys = [], content, id,
- is_persistent}).
-
--record(ssl_socket, {tcp, ssl}).
--record(delivery, {mandatory, immediate, sender, message, msg_seq_no}).
--record(amqp_error, {name, explanation = "", method = none}).
-
--record(event, {type, props, timestamp}).
-
--record(message_properties, {expiry, needs_confirming = false}).
-
--record(plugin, {name, %% atom()
- version, %% string()
- description, %% string()
- type, %% 'ez' or 'dir'
- dependencies, %% [{atom(), string()}]
- location}). %% string()
-
-%%----------------------------------------------------------------------------
-
--define(COPYRIGHT_MESSAGE, "Copyright (C) 2007-2012 VMware, Inc.").
--define(INFORMATION_MESSAGE, "Licensed under the MPL. See http://www.rabbitmq.com/").
--define(PROTOCOL_VERSION, "AMQP 0-9-1 / 0-9 / 0-8").
--define(ERTS_MINIMUM, "5.6.3").
-
--define(MAX_WAIT, 16#ffffffff).
-
--define(HIBERNATE_AFTER_MIN, 1000).
--define(DESIRED_HIBERNATE, 10000).
--define(CREDIT_DISC_BOUND, {2000, 500}).
-
--define(ROUTING_HEADERS, [<<"CC">>, <<"BCC">>]).
--define(DELETED_HEADER, <<"BCC">>).
View
31 lib/amqp_client-2.8.1/deps/rabbit_common-2.8.1/include/rabbit_auth_backend_spec.hrl
@@ -1,31 +0,0 @@
-%% The contents of this file are subject to the Mozilla Public License
-%% Version 1.1 (the "License"); you may not use this file except in
-%% compliance with the License. You may obtain a copy of the License
-%% at http://www.mozilla.org/MPL/
-%%
-%% 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 VMware, Inc.
-%% Copyright (c) 2007-2012 VMware, Inc. All rights reserved.
-%%
-
--ifdef(use_specs).
-
--spec(description/0 :: () -> [{atom(), any()}]).
-
--spec(check_user_login/2 :: (rabbit_types:username(), [term()]) ->
- {'ok', rabbit_types:user()} |
- {'refused', string(), [any()]} |
- {'error', any()}).
--spec(check_vhost_access/2 :: (rabbit_types:user(), rabbit_types:vhost()) ->
- boolean() | {'error', any()}).
--spec(check_resource_access/3 :: (rabbit_types:user(),
- rabbit_types:r(atom()),
- rabbit_access_control:permission_atom()) ->
- boolean() | {'error', any()}).
--endif.
View
28 lib/amqp_client-2.8.1/deps/rabbit_common-2.8.1/include/rabbit_auth_mechanism_spec.hrl
@@ -1,28 +0,0 @@
-%% The contents of this file are subject to the Mozilla Public License
-%% Version 1.1 (the "License"); you may not use this file except in
-%% compliance with the License. You may obtain a copy of the License
-%% at http://www.mozilla.org/MPL/
-%%
-%% 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 VMware, Inc.
-%% Copyright (c) 2007-2012 VMware, Inc. All rights reserved.
-%%
-
--ifdef(use_specs).
-
--spec(description/0 :: () -> [{atom(), any()}]).
--spec(should_offer/1 :: (rabbit_net:socket()) -> boolean()).
--spec(init/1 :: (rabbit_net:socket()) -> any()).
--spec(handle_response/2 :: (binary(), any()) ->
- {'ok', rabbit_types:user()} |
- {'challenge', binary(), any()} |
- {'protocol_error', string(), [any()]} |
- {'refused', string(), [any()]}).
-
--endif.
View
70 lib/amqp_client-2.8.1/deps/rabbit_common-2.8.1/include/rabbit_backing_queue_spec.hrl
@@ -1,70 +0,0 @@
-%% The contents of this file are subject to the Mozilla Public License
-%% Version 1.1 (the "License"); you may not use this file except in
-%% compliance with the License. You may obtain a copy of the License
-%% at http://www.mozilla.org/MPL/
-%%
-%% 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 VMware, Inc.
-%% Copyright (c) 2007-2012 VMware, Inc. All rights reserved.
-%%
-
--type(fetch_result(Ack) ::
- ('empty' |
- %% Message, IsDelivered, AckTag, Remaining_Len
- {rabbit_types:basic_message(), boolean(), Ack, non_neg_integer()})).
--type(is_durable() :: boolean()).
--type(attempt_recovery() :: boolean()).
--type(purged_msg_count() :: non_neg_integer()).
--type(confirm_required() :: boolean()).
--type(async_callback() :: fun ((atom(), fun ((atom(), state()) -> state())) -> 'ok')).
--type(duration() :: ('undefined' | 'infinity' | number())).
-
--type(msg_fun() :: fun((rabbit_types:basic_message(), ack()) -> 'ok')).
-
--spec(start/1 :: ([rabbit_amqqueue:name()]) -> 'ok').
--spec(stop/0 :: () -> 'ok').
--spec(init/3 :: (rabbit_types:amqqueue(), attempt_recovery(),
- async_callback()) -> state()).
--spec(terminate/2 :: (any(), state()) -> state()).
--spec(delete_and_terminate/2 :: (any(), state()) -> state()).
--spec(purge/1 :: (state()) -> {purged_msg_count(), state()}).
--spec(publish/4 :: (rabbit_types:basic_message(),
- rabbit_types:message_properties(), pid(), state()) ->
- state()).
--spec(publish_delivered/5 :: (true, rabbit_types:basic_message(),
- rabbit_types:message_properties(), pid(), state())
- -> {ack(), state()};
- (false, rabbit_types:basic_message(),
- rabbit_types:message_properties(), pid(), state())
- -> {undefined, state()}).
--spec(drain_confirmed/1 :: (state()) -> {[rabbit_guid:guid()], state()}).
--spec(dropwhile/3 ::
- (fun ((rabbit_types:message_properties()) -> boolean()),
- msg_fun() | 'undefined', state())
- -> state()).
--spec(fetch/2 :: (true, state()) -> {fetch_result(ack()), state()};
- (false, state()) -> {fetch_result(undefined), state()}).
--spec(ack/2 :: ([ack()], state()) -> {[rabbit_guid:guid()], state()}).
--spec(fold/3 :: (msg_fun(), state(), [ack()]) -> state()).
--spec(requeue/2 :: ([ack()], state())
- -> {[rabbit_guid:guid()], state()}).
--spec(len/1 :: (state()) -> non_neg_integer()).
--spec(is_empty/1 :: (state()) -> boolean()).
--spec(set_ram_duration_target/2 ::
- (duration(), state()) -> state()).
--spec(ram_duration/1 :: (state()) -> {duration(), state()}).
--spec(needs_timeout/1 :: (state()) -> 'false' | 'timed' | 'idle').
--spec(timeout/1 :: (state()) -> state()).
--spec(handle_pre_hibernate/1 :: (state()) -> state()).
--spec(status/1 :: (state()) -> [{atom(), any()}]).
--spec(invoke/3 :: (atom(), fun ((atom(), A) -> A), state()) -> state()).
--spec(is_duplicate/2 ::
- (rabbit_types:basic_message(), state()) ->
- {'false'|'published'|'discarded', state()}).
--spec(discard/3 :: (rabbit_types:basic_message(), pid(), state()) -> state()).
View
38 lib/amqp_client-2.8.1/deps/rabbit_common-2.8.1/include/rabbit_exchange_type_spec.hrl
@@ -1,38 +0,0 @@
-%% The contents of this file are subject to the Mozilla Public License
-%% Version 1.1 (the "License"); you may not use this file except in
-%% compliance with the License. You may obtain a copy of the License
-%% at http://www.mozilla.org/MPL/
-%%
-%% 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 VMware, Inc.
-%% Copyright (c) 2007-2012 VMware, Inc. All rights reserved.
-%%
-
--ifdef(use_specs).
-
--type(tx() :: 'transaction' | 'none').
--type(serial() :: pos_integer() | tx()).
-
--spec(description/0 :: () -> [{atom(), any()}]).
--spec(serialise_events/0 :: () -> boolean()).
--spec(route/2 :: (rabbit_types:exchange(), rabbit_types:delivery())
- -> rabbit_router:match_result()).
--spec(validate/1 :: (rabbit_types:exchange()) -> 'ok').
--spec(create/2 :: (tx(), rabbit_types:exchange()) -> 'ok').
--spec(delete/3 :: (tx(), rabbit_types:exchange(),
- [rabbit_types:binding()]) -> 'ok').
--spec(add_binding/3 :: (serial(), rabbit_types:exchange(),
- rabbit_types:binding()) -> 'ok').
--spec(remove_bindings/3 :: (serial(), rabbit_types:exchange(),
- [rabbit_types:binding()]) -> 'ok').
--spec(assert_args_equivalence/2 ::
- (rabbit_types:exchange(), rabbit_framing:amqp_table())
- -> 'ok' | rabbit_types:connection_exit()).
-
--endif.
View
0 lib/amqp_client-2.8.1/deps/rabbit_common-2.8.1/include/rabbit_framing.hrl
Sorry, we could not display the changes to this file because there were too many other changes to display.
View
0 lib/amqp_client-2.8.1/deps/rabbit_common-2.8.1/include/rabbit_msg_store.hrl
Sorry, we could not display the changes to this file because there were too many other changes to display.
View
45 lib/amqp_client-2.8.1/deps/rabbit_common-2.8.1/include/rabbit_msg_store_index.hrl
@@ -1,45 +0,0 @@
-%% The contents of this file are subject to the Mozilla Public License
-%% Version 1.1 (the "License"); you may not use this file except in
-%% compliance with the License. You may obtain a copy of the License
-%% at http://www.mozilla.org/MPL/
-%%
-%% 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 VMware, Inc.
-%% Copyright (c) 2007-2012 VMware, Inc. All rights reserved.
-%%
-
--include("rabbit_msg_store.hrl").
-
-%%----------------------------------------------------------------------------
-
--ifdef(use_specs).
-
--type(dir() :: any()).
--type(index_state() :: any()).
--type(keyvalue() :: any()).
--type(fieldpos() :: non_neg_integer()).
--type(fieldvalue() :: any()).
-
--spec(new/1 :: (dir()) -> index_state()).
--spec(recover/1 :: (dir()) -> rabbit_types:ok_or_error2(index_state(), any())).
--spec(lookup/2 ::
- (rabbit_types:msg_id(), index_state()) -> ('not_found' | keyvalue())).
--spec(insert/2 :: (keyvalue(), index_state()) -> 'ok').
--spec(update/2 :: (keyvalue(), index_state()) -> 'ok').
--spec(update_fields/3 :: (rabbit_types:msg_id(), ({fieldpos(), fieldvalue()} |
- [{fieldpos(), fieldvalue()}]),
- index_state()) -> 'ok').
--spec(delete/2 :: (rabbit_types:msg_id(), index_state()) -> 'ok').
--spec(delete_object/2 :: (keyvalue(), index_state()) -> 'ok').
--spec(delete_by_file/2 :: (fieldvalue(), index_state()) -> 'ok').
--spec(terminate/1 :: (index_state()) -> any()).
-
--endif.
-
-%%----------------------------------------------------------------------------
View
0 lib/amqp_client-2.8.1/deps/rabbit_common-2.8.1/src/.placeholder
No changes.
View
0 lib/amqp_client-2.8.1/ebin/.ignore
No changes.
View
0 lib/amqp_client-2.8.1/ebin/.placeholder
No changes.
View
74 lib/amqp_client-2.8.1/include/amqp_client.hrl
@@ -1,74 +0,0 @@
-%% The contents of this file are subject to the Mozilla Public License
-%% Version 1.1 (the "License"); you may not use this file except in
-%% compliance with the License. You may obtain a copy of the License at
-%% http://www.mozilla.org/MPL/
-%%
-%% 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 VMware, Inc.
-%% Copyright (c) 2007-2012 VMware, Inc. All rights reserved.
-%%
-
--ifndef(AMQP_CLIENT_HRL).
--define(AMQP_CLIENT_HRL, true).
-
--include_lib("rabbit_common/include/rabbit.hrl").
--include_lib("rabbit_common/include/rabbit_framing.hrl").
-
--define(PROTOCOL_VERSION_MAJOR, 0).
--define(PROTOCOL_VERSION_MINOR, 9).
--define(PROTOCOL_HEADER, <<"AMQP", 0, 0, 9, 1>>).
--define(PROTOCOL, rabbit_framing_amqp_0_9_1).
-
--define(MAX_CHANNEL_NUMBER, 65535).
--define(DEFAULT_CONSUMER, {amqp_selective_consumer, []}).
-
--define(PROTOCOL_SSL_PORT, (?PROTOCOL_PORT - 1)).
-
--record(amqp_msg, {props = #'P_basic'{}, payload = <<>>}).
-
--record(amqp_params_network, {username = <<"guest">>,
- password = <<"guest">>,
- virtual_host = <<"/">>,
- host = "localhost",
- port = undefined,
- channel_max = 0,
- frame_max = 0,
- heartbeat = 0,
- connection_timeout = infinity,
- ssl_options = none,
- auth_mechanisms =
- [fun amqp_auth_mechanisms:plain/3,
- fun amqp_auth_mechanisms:amqplain/3],
- client_properties = [],
- socket_options = []}).
-
--record(amqp_params_direct, {username = <<"guest">>,
- virtual_host = <<"/">>,
- node = node(),
- adapter_info = none,
- client_properties = []}).
-
--record(adapter_info, {address = unknown,
- port = unknown,
- peer_address = unknown,
- peer_port = unknown,
- name = unknown,
- protocol = unknown,
- additional_info = []}).
-
--define(LOG_DEBUG(Format), error_logger:info_msg(Format)).
--define(LOG_INFO(Format, Args), error_logger:info_msg(Format, Args)).
--define(LOG_WARN(Format, Args), error_logger:warning_msg(Format, Args)).
-
--define(CLIENT_CAPABILITIES, [{<<"publisher_confirms">>, bool, true},
- {<<"exchange_exchange_bindings">>, bool, true},
- {<<"basic.nack">>, bool, true},
- {<<"consumer_cancel_notify">>, bool, true}]).
-
--endif.
View
0 lib/amqp_client-2.8.1/include/amqp_gen_consumer_spec.hrl
Sorry, we could not display the changes to this file because there were too many other changes to display.
View
0 lib/amqp_client-2.8.1/src/amqp_auth_mechanisms.erl
Sorry, we could not display the changes to this file because there were too many other changes to display.
View
873 lib/amqp_client-2.8.1/src/amqp_channel.erl
@@ -1,873 +0,0 @@
-%% The contents of this file are subject to the Mozilla Public License
-%% Version 1.1 (the "License"); you may not use this file except in
-%% compliance with the License. You may obtain a copy of the License at
-%% http://www.mozilla.org/MPL/
-%%
-%% 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 VMware, Inc.
-%% Copyright (c) 2007-2012 VMware, Inc. All rights reserved.
-%%
-
-%% @type close_reason(Type) = {shutdown, amqp_reason(Type)}.
-%% @type amqp_reason(Type) = {Type, Code, Text}
-%% Code = non_neg_integer()
-%% Text = binary().
-%% @doc This module encapsulates the client's view of an AMQP
-%% channel. Each server side channel is represented by an amqp_channel
-%% process on the client side. Channel processes are created using the
-%% {@link amqp_connection} module. Channel processes are supervised
-%% under amqp_client's supervision tree.<br/>
-%% <br/>
-%% In case of a failure or an AMQP error, the channel process exits with a
-%% meaningful exit reason:<br/>
-%% <br/>
-%% <table>
-%% <tr>
-%% <td><strong>Cause</strong></td>
-%% <td><strong>Exit reason</strong></td>
-%% </tr>
-%% <tr>
-%% <td>Any reason, where Code would have been 200 otherwise</td>
-%% <td>```normal'''</td>
-%% </tr>
-%% <tr>
-%% <td>User application calls amqp_channel:close/3</td>
-%% <td>```close_reason(app_initiated_close)'''</td>
-%% </tr>
-%% <tr>
-%% <td>Server closes channel (soft error)</td>
-%% <td>```close_reason(server_initiated_close)'''</td>
-%% </tr>
-%% <tr>
-%% <td>Server misbehaved (did not follow protocol)</td>
-%% <td>```close_reason(server_misbehaved)'''</td>
-%% </tr>
-%% <tr>
-%% <td>Connection is closing (causing all channels to cleanup and
-%% close)</td>
-%% <td>```{shutdown, {connection_closing, amqp_reason(atom())}}'''</td>
-%% </tr>
-%% <tr>
-%% <td>Other error</td>
-%% <td>(various error reasons, causing more detailed logging)</td>
-%% </tr>
-%% </table>
-%% <br/>
-%% See type definitions below.
--module(amqp_channel).
-
--include("amqp_client.hrl").
-
--behaviour(gen_server).
-
--export([call/2, call/3, cast/2, cast/3, cast_flow/3]).
--export([close/1, close/3]).
--export([register_return_handler/2, register_flow_handler/2,
- register_confirm_handler/2]).
--export([call_consumer/2, subscribe/3]).
--export([next_publish_seqno/1, wait_for_confirms/1, wait_for_confirms/2,
- wait_for_confirms_or_die/1, wait_for_confirms_or_die/2]).
--export([start_link/5, connection_closing/3, open/1]).
-
--export([init/1, terminate/2, code_change/3, handle_call/3, handle_cast/2,
- handle_info/2]).
-
--define(TIMEOUT_FLUSH, 60000).
-
--record(state, {number,
- connection,
- consumer,
- driver,
- rpc_requests = queue:new(),
- closing = false, %% false |
- %% {just_channel, Reason} |
- %% {connection, Reason}
- writer,
- return_handler_pid = none,
- confirm_handler_pid = none,
- next_pub_seqno = 0,
- flow_active = true,
- flow_handler_pid = none,
- start_writer_fun,
- unconfirmed_set = gb_sets:new(),
- waiting_set = gb_trees:empty(),
- only_acks_received = true
- }).
-
-%%---------------------------------------------------------------------------
-%% Type Definitions
-%%---------------------------------------------------------------------------
-
-%% @type amqp_method().
-%% This abstract datatype represents the set of methods that comprise
-%% the AMQP execution model. As indicated in the overview, the
-%% attributes of each method in the execution model are described in
-%% the protocol documentation. The Erlang record definitions are
-%% autogenerated from a parseable version of the specification. Most
-%% fields in the generated records have sensible default values that
-%% you need not worry in the case of a simple usage of the client
-%% library.
-
-%% @type amqp_msg() = #amqp_msg{}.
-%% This is the content encapsulated in content-bearing AMQP methods. It
-%% contains the following fields:
-%% <ul>
-%% <li>props :: class_property() - A class property record, defaults to
-%% #'P_basic'{}</li>
-%% <li>payload :: binary() - The arbitrary data payload</li>
-%% </ul>
-
-%%---------------------------------------------------------------------------
-%% AMQP Channel API methods
-%%---------------------------------------------------------------------------
-
-%% @spec (Channel, Method) -> Result
-%% @doc This is equivalent to amqp_channel:call(Channel, Method, none).
-call(Channel, Method) ->
- gen_server:call(Channel, {call, Method, none, self()}, infinity).
-
-%% @spec (Channel, Method, Content) -> Result
-%% where
-%% Channel = pid()
-%% Method = amqp_method()
-%% Content = amqp_msg() | none
-%% Result = amqp_method() | ok | blocked | closing
-%% @doc This sends an AMQP method on the channel.
-%% For content bearing methods, Content has to be an amqp_msg(), whereas
-%% for non-content bearing methods, it needs to be the atom 'none'.<br/>
-%% In the case of synchronous methods, this function blocks until the
-%% corresponding reply comes back from the server and returns it.
-%% In the case of asynchronous methods, the function blocks until the method
-%% gets sent on the wire and returns the atom 'ok' on success.<br/>
-%% This will return the atom 'blocked' if the server has
-%% throttled the client for flow control reasons. This will return the
-%% atom 'closing' if the channel is in the process of shutting down.<br/>
-%% Note that for asynchronous methods, the synchronicity implied by
-%% 'call' only means that the client has transmitted the method to
-%% the broker. It does not necessarily imply that the broker has
-%% accepted responsibility for the message.
-call(Channel, Method, Content) ->
- gen_server:call(Channel, {call, Method, Content, self()}, infinity).
-
-%% @spec (Channel, Method) -> ok
-%% @doc This is equivalent to amqp_channel:cast(Channel, Method, none).
-cast(Channel, Method) ->
- gen_server:cast(Channel, {cast, Method, none, self(), noflow}).
-
-%% @spec (Channel, Method, Content) -> ok
-%% where
-%% Channel = pid()
-%% Method = amqp_method()
-%% Content = amqp_msg() | none
-%% @doc This function is the same as {@link call/3}, except that it returns
-%% immediately with the atom 'ok', without blocking the caller process.
-%% This function is not recommended with synchronous methods, since there is no
-%% way to verify that the server has received the method.
-cast(Channel, Method, Content) ->
- gen_server:cast(Channel, {cast, Method, Content, self(), noflow}).
-
-%% @spec (Channel, Method, Content) -> ok
-%% where
-%% Channel = pid()
-%% Method = amqp_method()
-%% Content = amqp_msg() | none
-%% @doc Like cast/3, with flow control.
-cast_flow(Channel, Method, Content) ->
- credit_flow:send(Channel),
- gen_server:cast(Channel, {cast, Method, Content, self(), flow}).
-
-%% @spec (Channel) -> ok | closing
-%% where
-%% Channel = pid()
-%% @doc Closes the channel, invokes
-%% close(Channel, 200, &lt;&lt;"Goodbye"&gt;&gt;).
-close(Channel) ->
- close(Channel, 200, <<"Goodbye">>).
-
-%% @spec (Channel, Code, Text) -> ok | closing
-%% where
-%% Channel = pid()
-%% Code = integer()
-%% Text = binary()
-%% @doc Closes the channel, allowing the caller to supply a reply code and
-%% text. If the channel is already closing, the atom 'closing' is returned.
-close(Channel, Code, Text) ->
- gen_server:call(Channel, {close, Code, Text}, infinity).
-
-%% @spec (Channel) -> integer()
-%% where
-%% Channel = pid()
-%% @doc When in confirm mode, returns the sequence number of the next
-%% message to be published.
-next_publish_seqno(Channel) ->
- gen_server:call(Channel, next_publish_seqno, infinity).
-
-%% @spec (Channel) -> boolean() | 'timeout'
-%% where
-%% Channel = pid()
-%% @doc Wait until all messages published since the last call have
-%% been either ack'd or nack'd by the broker. Note, when called on a
-%% non-Confirm channel, waitForConfirms returns true immediately.
-wait_for_confirms(Channel) ->
- wait_for_confirms(Channel, infinity).
-
-%% @spec (Channel, Timeout) -> boolean() | 'timeout'
-%% where
-%% Channel = pid()
-%% Timeout = non_neg_integer() | 'infinity'
-%% @doc Wait until all messages published since the last call have
-%% been either ack'd or nack'd by the broker or the timeout expires.
-%% Note, when called on a non-Confirm channel, waitForConfirms returns
-%% true immediately.
-wait_for_confirms(Channel, Timeout) ->
- gen_server:call(Channel, {wait_for_confirms, Timeout}, infinity).
-
-%% @spec (Channel) -> true
-%% where
-%% Channel = pid()
-%% @doc Behaves the same as wait_for_confirms/1, but if a nack is
-%% received, the calling process is immediately sent an
-%% exit(nack_received).
-wait_for_confirms_or_die(Channel) ->
- wait_for_confirms_or_die(Channel, infinity).
-
-%% @spec (Channel, Timeout) -> true
-%% where
-%% Channel = pid()
-%% Timeout = non_neg_integer() | 'infinity'
-%% @doc Behaves the same as wait_for_confirms/1, but if a nack is
-%% received, the calling process is immediately sent an
-%% exit(nack_received). If the timeout expires, the calling process is
-%% sent an exit(timeout).
-wait_for_confirms_or_die(Channel, Timeout) ->
- case wait_for_confirms(Channel, Timeout) of
- timeout -> close(Channel, 200, <<"Confirm Timeout">>),
- exit(timeout);
- false -> close(Channel, 200, <<"Nacks Received">>),
- exit(nacks_received);
- true -> true
- end.
-
-%% @spec (Channel, ReturnHandler) -> ok
-%% where
-%% Channel = pid()
-%% ReturnHandler = pid()
-%% @doc This registers a handler to deal with returned messages. The
-%% registered process will receive #basic.return{} records.
-register_return_handler(Channel, ReturnHandler) ->
- gen_server:cast(Channel, {register_return_handler, ReturnHandler} ).
-
-%% @spec (Channel, ConfirmHandler) -> ok
-%% where
-%% Channel = pid()
-%% ConfirmHandler = pid()
-
-%% @doc This registers a handler to deal with confirm-related
-%% messages. The registered process will receive #basic.ack{} and
-%% #basic.nack{} commands.
-register_confirm_handler(Channel, ConfirmHandler) ->
- gen_server:cast(Channel, {register_confirm_handler, ConfirmHandler} ).
-
-%% @spec (Channel, FlowHandler) -> ok
-%% where
-%% Channel = pid()
-%% FlowHandler = pid()
-%% @doc This registers a handler to deal with channel flow notifications.
-%% The registered process will receive #channel.flow{} records.
-register_flow_handler(Channel, FlowHandler) ->
- gen_server:cast(Channel, {register_flow_handler, FlowHandler} ).
-
-%% @spec (Channel, Msg) -> ok
-%% where
-%% Channel = pid()
-%% Msg = any()
-%% @doc This causes the channel to invoke Consumer:handle_call/2,
-%% where Consumer is the amqp_gen_consumer implementation registered with
-%% the channel.
-call_consumer(Channel, Msg) ->
- gen_server:call(Channel, {call_consumer, Msg}, infinity).
-
-%% @spec (Channel, BasicConsume, Subscriber) -> ok
-%% where
-%% Channel = pid()
-%% BasicConsume = amqp_method()
-%% Subscriber = pid()
-%% @doc Subscribe the given pid to a queue using the specified
-%% basic.consume method.
-subscribe(Channel, BasicConsume = #'basic.consume'{}, Subscriber) ->
- gen_server:call(Channel, {subscribe, BasicConsume, Subscriber}, infinity).
-
-%%---------------------------------------------------------------------------
-%% Internal interface
-%%---------------------------------------------------------------------------
-
-%% @private
-start_link(Driver, Connection, ChannelNumber, Consumer, SWF) ->
- gen_server:start_link(
- ?MODULE, [Driver, Connection, ChannelNumber, Consumer, SWF], []).
-
-%% @private
-connection_closing(Pid, ChannelCloseType, Reason) ->
- gen_server:cast(Pid, {connection_closing, ChannelCloseType, Reason}).
-
-%% @private
-open(Pid) ->
- gen_server:call(Pid, open, infinity).
-
-%%---------------------------------------------------------------------------
-%% gen_server callbacks
-%%---------------------------------------------------------------------------
-
-%% @private
-init([Driver, Connection, ChannelNumber, Consumer, SWF]) ->
- {ok, #state{connection = Connection,
- driver = Driver,
- number = ChannelNumber,
- consumer = Consumer,
- start_writer_fun = SWF}}.
-
-%% @private
-handle_call(open, From, State) ->
- {noreply, rpc_top_half(#'channel.open'{}, none, From, none, noflow, State)};
-%% @private
-handle_call({close, Code, Text}, From, State) ->
- handle_close(Code, Text, From, State);
-%% @private
-handle_call({call, Method, AmqpMsg, Sender}, From, State) ->
- handle_method_to_server(Method, AmqpMsg, From, Sender, noflow, State);
-%% Handles the delivery of messages from a direct channel
-%% @private
-handle_call({send_command_sync, Method, Content}, From, State) ->
- Ret = handle_method_from_server(Method, Content, State),
- gen_server:reply(From, ok),
- Ret;
-%% Handles the delivery of messages from a direct channel
-%% @private
-handle_call({send_command_sync, Method}, From, State) ->
- Ret = handle_method_from_server(Method, none, State),
- gen_server:reply(From, ok),
- Ret;
-%% @private
-handle_call(next_publish_seqno, _From,
- State = #state{next_pub_seqno = SeqNo}) ->
- {reply, SeqNo, State};
-handle_call({wait_for_confirms, Timeout}, From, State) ->
- handle_wait_for_confirms(From, Timeout, State);
-%% @private
-handle_call({call_consumer, Msg}, _From,
- State = #state{consumer = Consumer}) ->
- {reply, amqp_gen_consumer:call_consumer(Consumer, Msg), State};
-%% @private
-handle_call({subscribe, BasicConsume, Subscriber}, From, State) ->
- handle_method_to_server(BasicConsume, none, From, Subscriber, noflow,
- State).
-
-%% @private
-handle_cast({cast, Method, AmqpMsg, Sender, noflow}, State) ->
- handle_method_to_server(Method, AmqpMsg, none, Sender, noflow, State);
-handle_cast({cast, Method, AmqpMsg, Sender, flow}, State) ->
- credit_flow:ack(Sender),
- handle_method_to_server(Method, AmqpMsg, none, Sender, flow, State);
-%% @private
-handle_cast({register_return_handler, ReturnHandler}, State) ->
- erlang:monitor(process, ReturnHandler),
- {noreply, State#state{return_handler_pid = ReturnHandler}};
-%% @private
-handle_cast({register_confirm_handler, ConfirmHandler}, State) ->
- erlang:monitor(process, ConfirmHandler),
- {noreply, State#state{confirm_handler_pid = ConfirmHandler}};
-%% @private
-handle_cast({register_flow_handler, FlowHandler}, State) ->
- erlang:monitor(process, FlowHandler),
- {noreply, State#state{flow_handler_pid = FlowHandler}};
-%% Received from channels manager
-%% @private
-handle_cast({method, Method, Content, noflow}, State) ->
- handle_method_from_server(Method, Content, State);
-%% Handles the situation when the connection closes without closing the channel
-%% beforehand. The channel must block all further RPCs,
-%% flush the RPC queue (optional), and terminate
-%% @private
-handle_cast({connection_closing, CloseType, Reason}, State) ->
- handle_connection_closing(CloseType, Reason, State);
-%% @private
-handle_cast({shutdown, Shutdown}, State) ->
- handle_shutdown(Shutdown, State).
-
-%% Received from rabbit_channel in the direct case
-%% @private
-handle_info({send_command, Method}, State) ->
- handle_method_from_server(Method, none, State);
-%% Received from rabbit_channel in the direct case
-%% @private
-handle_info({send_command, Method, Content}, State) ->
- handle_method_from_server(Method, Content, State);
-%% Received from rabbit_channel in the direct case
-%% @private
-handle_info({send_command_and_notify, Q, ChPid, Method, Content}, State) ->
- handle_method_from_server(Method, Content, State),
- rabbit_amqqueue:notify_sent(Q, ChPid),
- {noreply, State};
-%% This comes from the writer or rabbit_channel
-%% @private
-handle_info({channel_exit, _ChNumber, Reason}, State) ->
- handle_channel_exit(Reason, State);
-%% This comes from rabbit_channel in the direct case
-handle_info({channel_closing, ChPid}, State) ->
- ok = rabbit_channel:ready_for_close(ChPid),
- {noreply, State};
-%% @private
-handle_info({bump_credit, Msg}, State) ->
- credit_flow:handle_bump_msg(Msg),
- {noreply, State};
-%% @private
-handle_info(timed_out_flushing_channel, State) ->
- ?LOG_WARN("Channel (~p) closing: timed out flushing while "
- "connection closing~n", [self()]),
- {stop, timed_out_flushing_channel, State};
-%% @private
-handle_info({'DOWN', _, process, ReturnHandler, Reason},
- State = #state{return_handler_pid = ReturnHandler}) ->
- ?LOG_WARN("Channel (~p): Unregistering return handler ~p because it died. "
- "Reason: ~p~n", [self(), ReturnHandler, Reason]),
- {noreply, State#state{return_handler_pid = none}};
-%% @private
-handle_info({'DOWN', _, process, ConfirmHandler, Reason},
- State = #state{confirm_handler_pid = ConfirmHandler}) ->
- ?LOG_WARN("Channel (~p): Unregistering confirm handler ~p because it died. "
- "Reason: ~p~n", [self(), ConfirmHandler, Reason]),
- {noreply, State#state{confirm_handler_pid = none}};
-%% @private
-handle_info({'DOWN', _, process, FlowHandler, Reason},
- State = #state{flow_handler_pid = FlowHandler}) ->
- ?LOG_WARN("Channel (~p): Unregistering flow handler ~p because it died. "
- "Reason: ~p~n", [self(), FlowHandler, Reason]),
- {noreply, State#state{flow_handler_pid = none}};
-handle_info({'DOWN', _, process, QPid, _Reason}, State) ->
- rabbit_amqqueue:notify_sent_queue_down(QPid),
- {noreply, State};
-handle_info({confirm_timeout, From}, State = #state{waiting_set = WSet}) ->
- case gb_trees:lookup(From, WSet) of
- none ->
- {noreply, State};
- {value, _} ->
- gen_server:reply(From, timeout),
- {noreply, State#state{waiting_set = gb_trees:delete(From, WSet)}}
- end.
-
-%% @private
-terminate(_Reason, State) ->
- State.
-
-%% @private
-code_change(_OldVsn, State, _Extra) ->
- State.
-
-%%---------------------------------------------------------------------------
-%% RPC mechanism
-%%---------------------------------------------------------------------------
-
-handle_method_to_server(Method, AmqpMsg, From, Sender, Flow,
- State = #state{unconfirmed_set = USet}) ->
- case {check_invalid_method(Method), From,
- check_block(Method, AmqpMsg, State)} of
- {ok, _, ok} ->
- State1 = case {Method, State#state.next_pub_seqno} of
- {#'confirm.select'{}, _} ->
- State#state{next_pub_seqno = 1};
- {#'basic.publish'{}, 0} ->
- State;
- {#'basic.publish'{}, SeqNo} ->
- State#state{unconfirmed_set =
- gb_sets:add(SeqNo, USet),
- next_pub_seqno = SeqNo + 1};
- _ ->
- State
- end,
- {noreply, rpc_top_half(Method, build_content(AmqpMsg),
- From, Sender, Flow, State1)};
- {ok, none, BlockReply} ->
- ?LOG_WARN("Channel (~p): discarding method ~p in cast.~n"
- "Reason: ~p~n", [self(), Method, BlockReply]),
- {noreply, State};
- {ok, _, BlockReply} ->
- {reply, BlockReply, State};
- {{_, InvalidMethodMessage}, none, _} ->
- ?LOG_WARN("Channel (~p): ignoring cast of ~p method. " ++
- InvalidMethodMessage ++ "~n", [self(), Method]),
- {noreply, State};
- {{InvalidMethodReply, _}, _, _} ->
- {reply, {error, InvalidMethodReply}, State}
- end.
-
-handle_close(Code, Text, From, State) ->
- Close = #'channel.close'{reply_code = Code,
- reply_text = Text,
- class_id = 0,
- method_id = 0},
- case check_block(Close, none, State) of
- ok -> {noreply, rpc_top_half(Close, none, From, none, noflow,
- State)};
- BlockReply -> {reply, BlockReply, State}
- end.
-
-rpc_top_half(Method, Content, From, Sender, Flow,
- State0 = #state{rpc_requests = RequestQueue}) ->
- State1 = State0#state{
- rpc_requests = queue:in({From, Sender, Method, Content, Flow},
- RequestQueue)},
- IsFirstElement = queue:is_empty(RequestQueue),
- if IsFirstElement -> do_rpc(State1);
- true -> State1
- end.
-
-rpc_bottom_half(Reply, State = #state{rpc_requests = RequestQueue}) ->
- {{value, {From, _Sender, _Method, _Content, _Flow}}, RequestQueue1} =
- queue:out(RequestQueue),
- case From of
- none -> ok;
- _ -> gen_server:reply(From, Reply)
- end,
- do_rpc(State#state{rpc_requests = RequestQueue1}).
-
-do_rpc(State = #state{rpc_requests = Q,
- closing = Closing}) ->
- case queue:out(Q) of
- {{value, {From, Sender, Method, Content, Flow}}, NewQ} ->
- State1 = pre_do(Method, Content, Sender, State),
- DoRet = do(Method, Content, Flow, State1),
- case ?PROTOCOL:is_method_synchronous(Method) of
- true -> State1;
- false -> case {From, DoRet} of
- {none, _} -> ok;
- {_, ok} -> gen_server:reply(From, ok);
- _ -> ok
- %% Do not reply if error in do. Expecting
- %% {channel_exit, ...}
- end,
- do_rpc(State1#state{rpc_requests = NewQ})
- end;
- {empty, NewQ} ->
- case Closing of
- {connection, Reason} ->
- gen_server:cast(self(),
- {shutdown, {connection_closing, Reason}});
- _ ->
- ok
- end,
- State#state{rpc_requests = NewQ}
- end.
-
-pending_rpc_method(#state{rpc_requests = Q}) ->
- {value, {_From, _Sender, Method, _Content, _Flow}} = queue:peek(Q),
- Method.
-
-pre_do(#'channel.open'{}, none, _Sender, State) ->
- start_writer(State);
-pre_do(#'channel.close'{reply_code = Code, reply_text = Text}, none,
- _Sender, State) ->
- State#state{closing = {just_channel, {app_initiated_close, Code, Text}}};
-pre_do(#'basic.consume'{} = Method, none, Sender, State) ->
- ok = call_to_consumer(Method, Sender, State),
- State;
-pre_do(_, _, _, State) ->
- State.
-
-%%---------------------------------------------------------------------------
-%% Handling of methods from the server
-%%---------------------------------------------------------------------------
-
-handle_method_from_server(Method, Content, State = #state{closing = Closing}) ->
- case is_connection_method(Method) of
- true -> server_misbehaved(
- #amqp_error{name = command_invalid,
- explanation = "connection method on "
- "non-zero channel",
- method = element(1, Method)},
- State);
- false -> Drop = case {Closing, Method} of
- {{just_channel, _}, #'channel.close'{}} -> false;
- {{just_channel, _}, #'channel.close_ok'{}} -> false;
- {{just_channel, _}, _} -> true;
- _ -> false
- end,
- if Drop -> ?LOG_INFO("Channel (~p): dropping method ~p from "
- "server because channel is closing~n",
- [self(), {Method, Content}]),
- {noreply, State};
- true -> handle_method_from_server1(Method,
- amqp_msg(Content), State)
- end
- end.
-
-handle_method_from_server1(#'channel.open_ok'{}, none, State) ->
- {noreply, rpc_bottom_half(ok, State)};
-handle_method_from_server1(#'channel.close'{reply_code = Code,
- reply_text = Text},
- none,
- State = #state{closing = {just_channel, _}}) ->
- %% Both client and server sent close at the same time. Don't shutdown yet,
- %% wait for close_ok.
- do(#'channel.close_ok'{}, none, noflow, State),
- {noreply,
- State#state{
- closing = {just_channel, {server_initiated_close, Code, Text}}}};
-handle_method_from_server1(#'channel.close'{reply_code = Code,
- reply_text = Text}, none, State) ->
- do(#'channel.close_ok'{}, none, noflow, State),
- handle_shutdown({server_initiated_close, Code, Text}, State);
-handle_method_from_server1(#'channel.close_ok'{}, none,
- State = #state{closing = Closing}) ->
- case Closing of
- {just_channel, {app_initiated_close, _, _} = Reason} ->
- handle_shutdown(Reason, rpc_bottom_half(ok, State));
- {just_channel, {server_initiated_close, _, _} = Reason} ->
- handle_shutdown(Reason,
- rpc_bottom_half(closing, State));
- {connection, Reason} ->
- handle_shutdown({connection_closing, Reason}, State)
- end;
-handle_method_from_server1(#'basic.consume_ok'{} = ConsumeOk, none, State) ->
- Consume = #'basic.consume'{} = pending_rpc_method(State),
- ok = call_to_consumer(ConsumeOk, Consume, State),
- {noreply, rpc_bottom_half(ConsumeOk, State)};
-handle_method_from_server1(#'basic.cancel_ok'{} = CancelOk, none, State) ->
- Cancel = #'basic.cancel'{} = pending_rpc_method(State),
- ok = call_to_consumer(CancelOk, Cancel, State),
- {noreply, rpc_bottom_half(CancelOk, State)};
-handle_method_from_server1(#'basic.cancel'{} = Cancel, none, State) ->
- ok = call_to_consumer(Cancel, none, State),
- {noreply, State};
-handle_method_from_server1(#'basic.deliver'{} = Deliver, AmqpMsg, State) ->
- ok = call_to_consumer(Deliver, AmqpMsg, State),
- {noreply, State};
-handle_method_from_server1(#'channel.flow'{active = Active} = Flow, none,
- State = #state{flow_handler_pid = FlowHandler}) ->
- case FlowHandler of none -> ok;
- _ -> FlowHandler ! Flow
- end,
- %% Putting the flow_ok in the queue so that the RPC queue can be
- %% flushed beforehand. Methods that made it to the queue are not
- %% blocked in any circumstance.
- {noreply, rpc_top_half(#'channel.flow_ok'{active = Active}, none, none,
- none, noflow, State#state{flow_active = Active})};
-handle_method_from_server1(
- #'basic.return'{} = BasicReturn, AmqpMsg,
- State = #state{return_handler_pid = ReturnHandler}) ->
- case ReturnHandler of
- none -> ?LOG_WARN("Channel (~p): received {~p, ~p} but there is no "
- "return handler registered~n",
- [self(), BasicReturn, AmqpMsg]);
- _ -> ReturnHandler ! {BasicReturn, AmqpMsg}
- end,
- {noreply, State};
-handle_method_from_server1(#'basic.ack'{} = BasicAck, none,
- #state{confirm_handler_pid = none} = State) ->
- ?LOG_WARN("Channel (~p): received ~p but there is no "
- "confirm handler registered~n", [self(), BasicAck]),
- {noreply, update_confirm_set(BasicAck, State)};
-handle_method_from_server1(
- #'basic.ack'{} = BasicAck, none,
- #state{confirm_handler_pid = ConfirmHandler} = State) ->
- ConfirmHandler ! BasicAck,
- {noreply, update_confirm_set(BasicAck, State)};
-handle_method_from_server1(#'basic.nack'{} = BasicNack, none,
- #state{confirm_handler_pid = none} = State) ->
- ?LOG_WARN("Channel (~p): received ~p but there is no "
- "confirm handler registered~n", [self(), BasicNack]),
- {noreply, update_confirm_set(BasicNack, State)};
-handle_method_from_server1(
- #'basic.nack'{} = BasicNack, none,
- #state{confirm_handler_pid = ConfirmHandler} = State) ->
- ConfirmHandler ! BasicNack,
- {noreply, update_confirm_set(BasicNack, State)};
-
-handle_method_from_server1(Method, none, State) ->
- {noreply, rpc_bottom_half(Method, State)};
-handle_method_from_server1(Method, Content, State) ->
- {noreply, rpc_bottom_half({Method, Content}, State)}.
-
-%%---------------------------------------------------------------------------
-%% Other handle_* functions
-%%---------------------------------------------------------------------------
-
-handle_connection_closing(CloseType, Reason,
- State = #state{rpc_requests = RpcQueue,
- closing = Closing}) ->
- NewState = State#state{closing = {connection, Reason}},
- case {CloseType, Closing, queue:is_empty(RpcQueue)} of
- {flush, false, false} ->
- erlang:send_after(?TIMEOUT_FLUSH, self(),
- timed_out_flushing_channel),
- {noreply, NewState};
- {flush, {just_channel, _}, false} ->
- {noreply, NewState};
- _ ->
- handle_shutdown({connection_closing, Reason}, NewState)
- end.
-
-handle_channel_exit(Reason, State = #state{connection = Connection}) ->
- case Reason of
- %% Sent by rabbit_channel in the direct case
- #amqp_error{name = ErrorName, explanation = Expl} ->
- ?LOG_WARN("Channel (~p) closing: server sent error ~p~n",
- [self(), Reason]),
- {IsHard, Code, _} = ?PROTOCOL:lookup_amqp_exception(ErrorName),
- ReportedReason = {server_initiated_close, Code, Expl},
- handle_shutdown(
- if IsHard ->
- amqp_gen_connection:hard_error_in_channel(
- Connection, self(), ReportedReason),
- {connection_closing, ReportedReason};
- true -> ReportedReason
- end, State);
- %% Unexpected death of a channel infrastructure process
- _ ->
- {stop, {infrastructure_died, Reason}, State}
- end.
-
-handle_shutdown({_, 200, _}, State) ->
- {stop, normal, State};
-handle_shutdown({connection_closing, {_, 200, _}}, State) ->
- {stop, normal, State};
-handle_shutdown({connection_closing, normal}, State) ->
- {stop, normal, State};
-handle_shutdown(Reason, State) ->
- {stop, {shutdown, Reason}, State}.
-
-%%---------------------------------------------------------------------------
-%% Internal plumbing
-%%---------------------------------------------------------------------------
-
-do(Method, Content, Flow, #state{driver = Driver, writer = W}) ->
- %% Catching because it expects the {channel_exit, _, _} message on error
- catch case {Driver, Content, Flow} of
- {network, none, _} -> rabbit_writer:send_command_sync(W, Method);
- {network, _, _} -> rabbit_writer:send_command_sync(W, Method,
- Content);
- {direct, none, _} -> rabbit_channel:do(W, Method);
- {direct, _, flow} -> rabbit_channel:do_flow(W, Method, Content);
- {direct, _, noflow} -> rabbit_channel:do(W, Method, Content)
- end.
-
-start_writer(State = #state{start_writer_fun = SWF}) ->
- {ok, Writer} = SWF(),
- State#state{writer = Writer}.
-
-amqp_msg(none) ->
- none;
-amqp_msg(Content) ->
- {Props, Payload} = rabbit_basic:from_content(Content),
- #amqp_msg{props = Props, payload = Payload}.
-
-build_content(none) ->
- none;
-build_content(#amqp_msg{props = Props, payload = Payload}) ->
- rabbit_basic:build_content(Props, Payload).
-
-check_block(_Method, _AmqpMsg, #state{closing = {just_channel, _}}) ->
- closing;
-check_block(_Method, _AmqpMsg, #state{closing = {connection, _}}) ->
- closing;
-check_block(_Method, none, #state{}) ->
- ok;
-check_block(_Method, #amqp_msg{}, #state{flow_active = false}) ->
- blocked;
-check_block(_Method, _AmqpMsg, #state{}) ->
- ok.
-
-check_invalid_method(#'channel.open'{}) ->
- {use_amqp_connection_module,
- "Use amqp_connection:open_channel/{1,2} instead"};
-check_invalid_method(#'channel.close'{}) ->
- {use_close_function, "Use close/{1,3} instead"};
-check_invalid_method(Method) ->
- case is_connection_method(Method) of
- true -> {connection_methods_not_allowed,
- "Sending connection methods is not allowed"};
- false -> ok
- end.
-
-is_connection_method(Method) ->
- {ClassId, _} = ?PROTOCOL:method_id(element(1, Method)),
- ?PROTOCOL:lookup_class_name(ClassId) == connection.
-
-server_misbehaved(#amqp_error{} = AmqpError, State = #state{number = Number}) ->
- case rabbit_binary_generator:map_exception(Number, AmqpError, ?PROTOCOL) of
- {0, _} ->
- handle_shutdown({server_misbehaved, AmqpError}, State);
- {_, Close} ->
- ?LOG_WARN("Channel (~p) flushing and closing due to soft "
- "error caused by the server ~p~n", [self(), AmqpError]),
- Self = self(),
- spawn(fun () -> call(Self, Close) end),
- {noreply, State}
- end.
-
-update_confirm_set(#'basic.ack'{delivery_tag = SeqNo,
- multiple = Multiple},
- State = #state{unconfirmed_set = USet}) ->
- maybe_notify_waiters(
- State#state{unconfirmed_set =
- update_unconfirmed(SeqNo, Multiple, USet)});
-update_confirm_set(#'basic.nack'{delivery_tag = SeqNo,
- multiple = Multiple},
- State = #state{unconfirmed_set = USet}) ->
- maybe_notify_waiters(
- State#state{unconfirmed_set = update_unconfirmed(SeqNo, Multiple, USet),
- only_acks_received = false}).
-
-update_unconfirmed(SeqNo, false, USet) ->
- gb_sets:del_element(SeqNo, USet);
-update_unconfirmed(SeqNo, true, USet) ->
- case gb_sets:is_empty(USet) of
- true -> USet;
- false -> {S, USet1} = gb_sets:take_smallest(USet),
- case S > SeqNo of
- true -> USet;
- false -> update_unconfirmed(SeqNo, true, USet1)
- end
- end.
-
-maybe_notify_waiters(State = #state{unconfirmed_set = USet}) ->
- case gb_sets:is_empty(USet) of
- false -> State;
- true -> notify_confirm_waiters(State)
- end.
-
-notify_confirm_waiters(State = #state{waiting_set = WSet,
- only_acks_received = OAR}) ->
- [begin
- safe_cancel_timer(TRef),
- gen_server:reply(From, OAR)
- end || {From, TRef} <- gb_trees:to_list(WSet)],
- State#state{waiting_set = gb_trees:empty(),
- only_acks_received = true}.
-
-handle_wait_for_confirms(From, Timeout,
- State = #state{unconfirmed_set = USet,
- waiting_set = WSet}) ->
- case gb_sets:is_empty(USet) of
- true ->
- {reply, true, State};
- false ->
- TRef = case Timeout of
- infinity -> undefined;
- _ -> erlang:send_after(Timeout * 1000, self(),
- {confirm_timeout, From})
- end,
- {noreply,
- State#state{waiting_set = gb_trees:insert(From, TRef, WSet)}}
- end.
-
-call_to_consumer(Method, Args, #state{consumer = Consumer}) ->
- amqp_gen_consumer:call_consumer(Consumer, Method, Args).
-
-safe_cancel_timer(undefined) -> ok;
-safe_cancel_timer(TRef) -> erlang:cancel_timer(TRef).
View
79 lib/amqp_client-2.8.1/src/amqp_channel_sup.erl
@@ -1,79 +0,0 @@
-%% The contents of this file are subject to the Mozilla Public License
-%% Version 1.1 (the "License"); you may not use this file except in
-%% compliance with the License. You may obtain a copy of the License at
-%% http://www.mozilla.org/MPL/
-%%
-%% 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 VMware, Inc.
-%% Copyright (c) 2007-2012 VMware, Inc. All rights reserved.
-%%
-
-%% @private
--module(amqp_channel_sup).
-
--include("amqp_client.hrl").
-
--behaviour(supervisor2).
-
--export([start_link/5]).
--export([init/1]).
-
-%%---------------------------------------------------------------------------
-%% Interface
-%%---------------------------------------------------------------------------
-
-start_link(Type, Connection, InfraArgs, ChNumber, Consumer = {_, _}) ->
- {ok, Sup} = supervisor2:start_link(?MODULE, [Consumer]),
- [{gen_consumer, ConsumerPid, _, _}] = supervisor2:which_children(Sup),
- {ok, ChPid} = supervisor2:start_child(
- Sup, {channel, {amqp_channel, start_link,
- [Type, Connection, ChNumber, ConsumerPid,
- start_writer_fun(Sup, Type, InfraArgs,
- ChNumber)]},
- intrinsic, ?MAX_WAIT, worker, [amqp_channel]}),
- {ok, AState} = init_command_assembler(Type),
- {ok, Sup, {ChPid, AState}}.
-
-%%---------------------------------------------------------------------------
-%% Internal plumbing
-%%---------------------------------------------------------------------------
-
-start_writer_fun(_Sup, direct, [ConnPid, ConnName, Node, User, VHost,
- Collector],
- ChNumber) ->
- fun () ->
- {ok, RabbitCh} =
- rpc:call(Node, rabbit_direct, start_channel,
- [ChNumber, self(), ConnPid, ConnName, ?PROTOCOL, User,
- VHost, ?CLIENT_CAPABILITIES, Collector]),
- link(RabbitCh),
- {ok, RabbitCh}
- end;
-start_writer_fun(Sup, network, [Sock], ChNumber) ->
- fun () ->
- {ok, _} = supervisor2:start_child(
- Sup,
- {writer, {rabbit_writer, start_link,
- [Sock, ChNumber, ?FRAME_MIN_SIZE, ?PROTOCOL,
- self()]},
- intrinsic, ?MAX_WAIT, worker, [rabbit_writer]})
- end.
-
-init_command_assembler(direct) -> {ok, none};
-init_command_assembler(network) -> rabbit_command_assembler:init(?PROTOCOL).
-
-%%---------------------------------------------------------------------------
-%% supervisor2 callbacks
-%%---------------------------------------------------------------------------
-
-init([{ConsumerModule, ConsumerArgs}]) ->
- {ok, {{one_for_all, 0, 1},
- [{gen_consumer, {amqp_gen_consumer, start_link,
- [ConsumerModule, ConsumerArgs]},
- intrinsic, ?MAX_WAIT, worker, [amqp_gen_consumer]}]}}.
View
0 lib/amqp_client-2.8.1/src/amqp_channel_sup_sup.erl
Sorry, we could not display the changes to this file because there were too many other changes to display.
View
255 lib/amqp_client-2.8.1/src/amqp_channels_manager.erl
@@ -1,255 +0,0 @@
-%% The contents of this file are subject to the Mozilla Public License
-%% Version 1.1 (the "License"); you may not use this file except in
-%% compliance with the License. You may obtain a copy of the License at
-%% http://www.mozilla.org/MPL/
-%%
-%% 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 VMware, Inc.
-%% Copyright (c) 2007-2012 VMware, Inc. All rights reserved.
-%%
-
-%% @private
--module(amqp_channels_manager).
-
--include("amqp_client.hrl").
-
--behaviour(gen_server).
-
--export([start_link/2, open_channel/4, set_channel_max/2, is_empty/1,
- num_channels/1, pass_frame/3, signal_connection_closing/3,
- process_channel_frame/4]).
--export([init/1, terminate/2, code_change/3, handle_call/3, handle_cast/2,
- handle_info/2]).
-
--record(state, {connection,
- channel_sup_sup,
- map_num_pa = gb_trees:empty(), %% Number -> {Pid, AState}
- map_pid_num = dict:new(), %% Pid -> Number
- channel_max = ?MAX_CHANNEL_NUMBER,
- closing = false}).
-
-%%---------------------------------------------------------------------------
-%% Interface
-%%---------------------------------------------------------------------------
-
-start_link(Connection, ChSupSup) ->
- gen_server:start_link(?MODULE, [Connection, ChSupSup], []).
-
-open_channel(ChMgr, ProposedNumber, Consumer, InfraArgs) ->
- gen_server:call(ChMgr, {open_channel, ProposedNumber, Consumer, InfraArgs},
- infinity).
-
-set_channel_max(ChMgr, ChannelMax) ->
- gen_server:cast(ChMgr, {set_channel_max, ChannelMax}).
-
-is_empty(ChMgr) ->
- gen_server:call(ChMgr, is_empty, infinity).
-
-num_channels(ChMgr) ->
- gen_server:call(ChMgr, num_channels, infinity).
-
-pass_frame(ChMgr, ChNumber, Frame) ->
- gen_server:cast(ChMgr, {pass_frame, ChNumber, Frame}).
-
-signal_connection_closing(ChMgr, ChannelCloseType, Reason) ->
- gen_server:cast(ChMgr, {connection_closing, ChannelCloseType, Reason}).
-
-process_channel_frame(Frame, Channel, ChPid, AState) ->
- case rabbit_command_assembler:process(Frame, AState) of
- {ok, NewAState} -> NewAState;
- {ok, Method, NewAState} -> rabbit_channel:do(ChPid, Method),
- NewAState;
- {ok, Method, Content, NewAState} -> rabbit_channel:do(ChPid, Method,
- Content),
- NewAState;
- {error, Reason} -> ChPid ! {channel_exit, Channel,
- Reason},
- AState
- end.
-
-%%---------------------------------------------------------------------------
-%% gen_server callbacks
-%%---------------------------------------------------------------------------
-
-init([Connection, ChSupSup]) ->
- {ok, #state{connection = Connection, channel_sup_sup = ChSupSup}}.
-
-terminate(_Reason, _State) ->
- ok.
-
-code_change(_OldVsn, State, _Extra) ->
- State.
-
-handle_call({open_channel, ProposedNumber, Consumer, InfraArgs}, _,
- State = #state{closing = false}) ->
- handle_open_channel(ProposedNumber, Consumer, InfraArgs, State);
-handle_call(is_empty, _, State) ->
- {reply, internal_is_empty(State), State};
-handle_call(num_channels, _, State) ->
- {reply, internal_num_channels(State), State}.
-
-handle_cast({set_channel_max, ChannelMax}, State) ->
- {noreply, State#state{channel_max = ChannelMax}};
-handle_cast({pass_frame, ChNumber, Frame}, State) ->
- {noreply, internal_pass_frame(ChNumber, Frame, State)};
-handle_cast({connection_closing, ChannelCloseType, Reason}, State) ->
- handle_connection_closing(ChannelCloseType, Reason, State).
-
-handle_info({'DOWN', _, process, Pid, Reason}, State) ->
- handle_down(Pid, Reason, State).
-
-%%---------------------------------------------------------------------------
-%% Internal plumbing
-%%---------------------------------------------------------------------------
-
-handle_open_channel(ProposedNumber, Consumer, InfraArgs,
- State = #state{channel_sup_sup = ChSupSup}) ->
- case new_number(ProposedNumber, State) of
- {ok, Number} ->
- {ok, _ChSup, {Ch, AState}} =
- amqp_channel_sup_sup:start_channel_sup(ChSupSup, InfraArgs,
- Number, Consumer),
- NewState = internal_register(Number, Ch, AState, State),
- erlang:monitor(process, Ch),
- {reply, {ok, Ch}, NewState};
- {error, _} = Error ->
- {reply, Error, State}
- end.
-
-new_number(none, #state{channel_max = ChannelMax, map_num_pa = MapNPA}) ->
- case gb_trees:is_empty(MapNPA) of