module Mumukit::Nuntius

Constants

Logger
VERSION

Public Class Methods

defaults() click to toggle source
# 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_connection() click to toggle source
# File lib/mumukit/nuntius.rb, line 54
def self.ensure_connection
  establish_connection rescue nil
end
establish_connection() click to toggle source
# File lib/mumukit/nuntius.rb, line 50
def self.establish_connection
  notification_mode.establish_connection
end
notify!(queue_name, message) click to toggle source

Notifies a message to a given queue.

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

@param [String|Symbol] queue_name the name of the queue to which publish this message @param [Hash] message a json-like hash with the message data.

# 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) click to toggle source

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

@param [String|Symbol] type the type of event. @param [Hash] event a json-like hash with the event data

# File lib/mumukit/nuntius.rb, line 46
def self.notify_event!(type, event, **options)
  notification_mode.notify_event! type, event, **options
end

Private Class Methods

notification_mode() click to toggle source
# File lib/mumukit/nuntius.rb, line 60
def self.notification_mode
  Mumukit::Nuntius.config.notification_mode
end