Module: Mumukit::Nuntius

Extended by:
Core::Configurable
Defined in:
lib/mumukit/nuntius.rb,
lib/mumukit/nuntius/version.rb

Defined Under Namespace

Modules: Consumer, EventConsumer, EventPublisher, JobConsumer, JobPublisher, NotificationMode, Publisher, TaskConsumer Classes: Connection

Constant Summary collapse

Logger =
::Logger.new('nuntius.log')
VERSION =
'6.7.1'

Class Method Summary collapse

Class Method Details

.defaultsObject



12
13
14
15
16
# File 'lib/mumukit/nuntius.rb', line 12

def self.defaults
  struct.tap do |config|
    config.notification_mode = Mumukit::Nuntius::NotificationMode.from_env
  end
end

.ensure_connectionObject



76
77
78
# File 'lib/mumukit/nuntius.rb', line 76

def self.ensure_connection
  establish_connection rescue nil
end

.establish_connectionObject



72
73
74
# File 'lib/mumukit/nuntius.rb', line 72

def self.establish_connection
  notification_mode.establish_connection
end

.notify!(queue_name, message) ⇒ Object

Notifies a message to a given queue.

Messages are consumed using the Mumukit::Nuntius::Consumer module

Parameters:

  • queue_name (String|Symbol)

    the name of the queue to which publish this message

  • message (Hash)

    a json-like hash with the message data.



24
25
26
# File 'lib/mumukit/nuntius.rb', line 24

def self.notify!(queue_name, message)
  notification_mode.notify! queue_name, message
end

.notify_event!(type, event, **options) ⇒ Object

Notifies an event of the given type.

Events are very similar to normal messages, with the following differences:

* they are published to a single queue, named `events`
* event data is augmented with the sender app name,
  so that consumers can discard events sent from themselves.

This makes events lighter and easier to send. You should send application events to here unless:

* you expect to send alot of those events
* you expect those events processing to be slow

Events are consumed using the Mumukit::Nuntius::EventConsumer module

Parameters:

  • type (String|Symbol)

    the type of event.

  • event (Hash)

    a json-like hash with the event data



46
47
48
# File 'lib/mumukit/nuntius.rb', line 46

def self.notify_event!(type, event, **options)
  notification_mode.notify_event! type, event, **options
end

.notify_job!(type, job) ⇒ Object

Notifies a job of the given type.

Jobs are very similar to normal messages, with the following differences:

* they are published to a single queue, named `jobs`
* job data is augmented with the sender app name,
  so that consumers can consume only jobs sent from themselves.

This makes jobs lighter and easier to send. You should send application jobs to here if:

* you expect to send a lot of those jobs
* you expect those jobs processing to be slow

Events are consumed using the Mumukit::Nuntius::JobConsumer module

Parameters:

  • type (String|Symbol)

    the type of job.

  • job (Hash)

    a json-like hash with the job data



68
69
70
# File 'lib/mumukit/nuntius.rb', line 68

def self.notify_job!(type, job)
  notification_mode.notify_job! type, job
end