mumukit-nuntius 2.4.3 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a8f1d1573c2de21887bd8390c01629c63d2ae722
4
- data.tar.gz: 25987bee4f879611574206a934f2c11a996f9c8e
3
+ metadata.gz: fe071f5cc4f9bce9ae28df16f68349b02a574052
4
+ data.tar.gz: 22d772031301a4e771ada31b2b59dc1706c146c7
5
5
  SHA512:
6
- metadata.gz: f370d74d9d04e43d95852e4463ee0f04ea52ac8fd13c479d1795ecbc406a3e34e4b9a7040d1ce1947c27001578eda83e1770806f33d97fd5eb1b8c35546e0154
7
- data.tar.gz: 974fd36d3d451fb7640f14d174f5f4118bfd82aa44ffdebfbe85ca3c2934f33271f0dba7eab2097ad04ef6daa7d6dd9681178255098e1b9ebe9256590bfce10f
6
+ metadata.gz: 8f8a569b991606d6d3daac7c414770e535129baaa4e594a787aa53ae783ab41556efd65e3a55c0a8ea630d41fab09c812157b809a3fa226000420074026be7a6
7
+ data.tar.gz: e1cf82ba69c6276ca10695c2a03a41043303eda6dfe23c82d987eb8cd6e4ff01dc08210f7a140d874f80607c039102b2359fc45543ceeb114ca52904282e1e81
@@ -8,16 +8,56 @@ module Mumukit
8
8
  Logger = ::Logger.new('nuntius.log')
9
9
 
10
10
  def self.configure
11
- @config ||= OpenStruct.new
11
+ @config ||= defaults
12
12
  yield @config
13
13
  end
14
14
 
15
+ def self.defaults
16
+ struct.tap do |config|
17
+ config.notification_mode = Mumukit::Nuntius::NotificationMode.from_env
18
+ end
19
+ end
20
+
15
21
  def self.config
16
22
  @config
17
23
  end
18
24
 
19
- def self.method_missing(name, *args, &block)
20
- Mumukit::Nuntius.config.notification_mode.send(name, *args, &block)
25
+ # Notifies a message to a given queue.
26
+ #
27
+ # Messages are consumed using the Mumukit::Nuntius::Consumer module
28
+ #
29
+ # @param [String|Symbol] queue_name the name of the queue to which publish this message
30
+ # @param [Hash] message a json-like hash with the message data.
31
+ def self.notify!(queue_name, message)
32
+ notification_mode.notify! queue_name, message
33
+ end
34
+
35
+ # Notifies an event of the given type.
36
+ #
37
+ # Events are very similar to normal messages, with the following differences:
38
+ #
39
+ # * they are published to a single queue, named `events`
40
+ # * event data is augmented with the sender app name,
41
+ # so that consumers can discard events sent from themselves.
42
+ #
43
+ # This makes events lighter and easier to send. You should send application
44
+ # events to here unless:
45
+ #
46
+ # * you expect to send alot of those events
47
+ # * you expect those events processing to be slow
48
+ #
49
+ # Events are consumed using the Mumukit::Nuntius::EventConsumer module
50
+ #
51
+ # @param [String|Symbol] type the type of event.
52
+ # @param [Hash] event a json-like hash with the event data
53
+ def self.notify_event!(type, event)
54
+ notification_mode.notify_event! type, event
55
+ end
56
+
57
+ private
58
+
59
+ def self.notification_mode
60
+ Mumukit::Nuntius.config.notification_mode
21
61
  end
22
62
  end
23
63
  end
@@ -4,7 +4,7 @@ module Mumukit::Nuntius::NotificationMode
4
4
  Mumukit::Nuntius::Publisher.publish queue_name, event
5
5
  end
6
6
 
7
- def notify_event!(data, type)
7
+ def notify_event!(type, data)
8
8
  Mumukit::Nuntius::EventPublisher.publish type, data
9
9
  end
10
10
  end
@@ -1,5 +1,5 @@
1
1
  module Mumukit
2
2
  module Nuntius
3
- VERSION = '2.4.3'
3
+ VERSION = '3.0.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mumukit-nuntius
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.3
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Agustin Pina
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-19 00:00:00.000000000 Z
11
+ date: 2017-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler