Skip to content

Commit ca2bdfb

Browse files
committed
Rabbit registry: Dinamically allow to define new classes
rabbit_registry classes are currently static, hard-coded in rabbit registry. Dinamically searching for new classes using Erlang attributes allows for plugins to add new classes and make use of the registry. i.e. shovel protocols can benefit of this feature
1 parent e49ed93 commit ca2bdfb

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

deps/rabbit_common/src/rabbit_registry.erl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,18 @@ class_module(policy_validator) -> rabbit_policy_validator;
190190
class_module(operator_policy_validator) -> rabbit_policy_validator;
191191
class_module(policy_merge_strategy) -> rabbit_policy_merge_strategy;
192192
class_module(ha_mode) -> rabbit_mirror_queue_mode;
193-
class_module(channel_interceptor) -> rabbit_channel_interceptor.
193+
class_module(channel_interceptor) -> rabbit_channel_interceptor;
194+
class_module(Other) ->
195+
AttrsPerApp = rabbit_misc:rabbitmq_related_module_attributes(rabbit_registry_class),
196+
find_class_module(Other, AttrsPerApp).
197+
198+
find_class_module(Class, [{_, Module, List} | Rest]) ->
199+
case lists:member(Class, List) of
200+
true -> Module;
201+
false -> find_class_module(Class, Rest)
202+
end;
203+
find_class_module(Class, []) ->
204+
throw({invalid_class, Class}).
194205

195206
%%---------------------------------------------------------------------------
196207

0 commit comments

Comments
 (0)