messaging 3.4.1 → 3.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +1 -1
- data/.gitignore +1 -0
- data/Gemfile +3 -2
- data/Gemfile.lock +278 -79
- data/README.md +2 -52
- data/_config.yml +78 -1
- data/_data/navigation.yml +17 -0
- data/_layouts/single.html +95 -0
- data/docs/adapters.md +4 -0
- data/docs/consuming.md +4 -0
- data/docs/installation.md +4 -0
- data/docs/messages.md +13 -0
- data/docs/publishing.md +4 -0
- data/docs/routing_and_handlers.md +64 -0
- data/lib/messaging.rb +23 -1
- data/lib/messaging/adapters.rb +2 -0
- data/lib/messaging/adapters/postgres/categories.rb +27 -0
- data/lib/messaging/adapters/postgres/category.rb +40 -0
- data/lib/messaging/adapters/postgres/serialized_message.rb +2 -0
- data/lib/messaging/adapters/postgres/store.rb +23 -0
- data/lib/messaging/adapters/postgres/stream.rb +4 -0
- data/lib/messaging/adapters/test/categories.rb +19 -0
- data/lib/messaging/adapters/test/category.rb +21 -0
- data/lib/messaging/adapters/test/store.rb +20 -0
- data/lib/messaging/adapters/test/stream.rb +4 -0
- data/lib/messaging/message.rb +12 -0
- data/lib/messaging/rails/railtie.rb +1 -1
- data/lib/messaging/routes.rb +15 -2
- data/lib/messaging/routing.rb +41 -15
- data/lib/messaging/routing/{background_job_subscriber.rb → enqueued_route.rb} +2 -2
- data/lib/messaging/routing/message_matcher.rb +4 -18
- data/lib/messaging/routing/{subscriber.rb → route.rb} +6 -6
- data/lib/messaging/version.rb +1 -1
- data/messaging.gemspec +1 -1
- metadata +18 -8
- data/lib/messaging/base_handler.rb +0 -45
@@ -1,45 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Messaging
|
4
|
-
# @private
|
5
|
-
# @deprecated
|
6
|
-
class BaseHandler
|
7
|
-
class << self
|
8
|
-
def only_messages(messages = nil)
|
9
|
-
@only_messages = Array(messages) if messages
|
10
|
-
@only_messages || []
|
11
|
-
end
|
12
|
-
alias only_message only_messages
|
13
|
-
|
14
|
-
def group_id(group_id = nil)
|
15
|
-
@group_id = group_id if group_id
|
16
|
-
@group_id || default_group_id
|
17
|
-
end
|
18
|
-
|
19
|
-
def default_group_id
|
20
|
-
Config.app_name + '-' + name.underscore
|
21
|
-
end
|
22
|
-
|
23
|
-
def call(message)
|
24
|
-
return unless allowed_message?(message.class)
|
25
|
-
|
26
|
-
new.on_message(message, nil)
|
27
|
-
end
|
28
|
-
|
29
|
-
def listen_on(topic:)
|
30
|
-
topics = Array(topic).map(&:to_s)
|
31
|
-
Messaging.routes.consumer(name, group_id: group_id) do |c|
|
32
|
-
topics.each { |t| c.on(/.*/, topic: t, call: self) }
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def allowed_message?(message_class)
|
37
|
-
return true if only_messages.empty?
|
38
|
-
|
39
|
-
only_messages.include? message_class
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def on_message(message, _metadata); end
|
44
|
-
end
|
45
|
-
end
|