Permalink
Browse files

first import

  • Loading branch information...
videlalvaro committed May 10, 2011
0 parents commit 68ab94d9a8884769c3c871cf5d63b9c6b3233ca0
@@ -0,0 +1,4 @@
+.DS_Store
+deps
+dist
+ebin
@@ -0,0 +1,21 @@
+The MIT License
+
+Copyright (c) 2011 Alvaro Videla
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
@@ -0,0 +1,37 @@
+PACKAGE=global-fanout-exchange
+DIST_DIR=dist
+EBIN_DIR=ebin
+INCLUDE_DIRS=include
+DEPS_DIR=deps
+DEPS ?=
+DEPS_EZ=$(foreach DEP, $(DEPS), $(DEPS_DIR)/$(DEP).ez)
+RABBITMQ_HOME ?= .
+
+all: compile
+
+clean:
+ rm -rf $(DIST_DIR)
+ rm -rf $(EBIN_DIR)
+
+distclean: clean
+ rm -rf $(DEPS_DIR)
+
+package: compile $(DEPS_EZ)
+ rm -f $(DIST_DIR)/$(PACKAGE).ez
+ mkdir -p $(DIST_DIR)/$(PACKAGE)
+ cp -r $(EBIN_DIR) $(DIST_DIR)/$(PACKAGE)
+ $(foreach EXTRA_DIR, $(INCLUDE_DIRS), cp -r $(EXTRA_DIR) $(DIST_DIR)/$(PACKAGE);)
+ (cd $(DIST_DIR); zip -r $(PACKAGE).ez $(PACKAGE))
+
+install: package
+ $(foreach DEP, $(DEPS_EZ), cp $(DEP) $(RABBITMQ_HOME)/plugins;)
+ cp $(DIST_DIR)/$(PACKAGE).ez $(RABBITMQ_HOME)/plugins
+
+$(DEPS_DIR):
+ ./rebar get-deps
+
+$(DEPS_EZ):
+ cd $(DEPS_DIR); $(foreach DEP, $(DEPS), zip -r $(DEP).ez $(DEP);)
+
+compile: $(DEPS_DIR)
+ rebar compile
@@ -0,0 +1,18 @@
+# RabbitMQ Global Fanout Exchange #
+
+Fanouts a message to **every queue in the broker** no matter the bindings. Created upon request from [@michaelklishin](http://twitter.com/#!/michaelklishin) during a fun chat at #rabbitmq on Freenode.
+
+**Use with care!** It was deveoped in under 30 minutes.
+
+Exchange Type: `x-global-fanout`
+
+## Installation ##
+
+ git clone git://github.com/videlalvaro/rabbitmq-global-fanout-exchange.git
+ cd rabbitmq-global-fanout-exchange
+ make package
+ cp dist/*.ez $RABBITMQ_HOME/plugins
+
+## License ##
+
+See LICENSE.md
No changes.
@@ -0,0 +1,5 @@
+{
+ deps, [
+ {rabbit_common, ".*", {git, "https://github.com/jbrisbin/rabbit_common.git", "HEAD"}}
+ ]
+}.
@@ -0,0 +1,26 @@
+-module(rabbit_exchange_type_global_fanout).
+-include_lib("rabbit_common/include/rabbit.hrl").
+
+-behaviour(rabbit_exchange_type).
+
+-export([description/0, route/2]).
+-export([validate/1, create/2, recover/2, delete/3,
+ add_binding/3, remove_bindings/3, assert_args_equivalence/2]).
+
+-include_lib("rabbit_common/include/rabbit_exchange_type_spec.hrl").
+
+description() ->
+ [{name, <<"global-fanout">>},
+ {description, <<"Fanouts messages to every queue in the broker.">>}].
+
+route(_, _) ->
+ rabbit_router:match_routing_key('_', ['_']).
+
+validate(_X) -> ok.
+create(_Tx, _X) -> ok.
+recover(_X, _Bs) -> ok.
+delete(_Tx, _X, _Bs) -> ok.
+add_binding(_Tx, _X, _B) -> ok.
+remove_bindings(_Tx, _X, _Bs) -> ok.
+assert_args_equivalence(X, Args) ->
+ rabbit_exchange:assert_args_equivalence(X, Args).
@@ -0,0 +1,7 @@
+-module(rabbit_global_fanout_plugin).
+
+-rabbit_boot_step({?MODULE,
+ [{description, "global fanout exchange type"},
+ {mfa, {rabbit_registry, register, [exchange, <<"x-global-fanout">>, rabbit_exchange_type_global_fanout]}},
+ {requires, rabbit_registry},
+ {enables, exchange_recovery}]}).
@@ -0,0 +1,10 @@
+{application, rabbitmq_global_fanout_exchange,
+ [
+ {description, "RabbitMQ Global Fanout Exchange"},
+ {vsn, "0.1.0"},
+ {modules, []},
+ {registered, []},
+ {env, []},
+ {applications, [kernel, stdlib, rabbit, mnesia]}
+ ]
+}.

0 comments on commit 68ab94d

Please sign in to comment.