Module: Isimud

Includes:
ActiveSupport::Configurable
Defined in:
lib/isimud/event_observer.rb,
lib/isimud.rb,
lib/isimud/event.rb,
lib/isimud/client.rb,
lib/isimud/logging.rb,
lib/isimud/railtie.rb,
lib/isimud/version.rb,
lib/isimud/test_client.rb,
lib/isimud/bunny_client.rb,
lib/isimud/model_watcher.rb,
lib/isimud/event_listener.rb,
lib/rails/generators/isimud/config_generator.rb,
lib/rails/generators/isimud/initializer_generator.rb

Overview

Module for attaching and listening to events

Note: the following columns must be defined in your model:

:exchange_routing_keys text

Defined Under Namespace

Modules: EventObserver, Generators, Logging, ModelWatcher Classes: BunnyClient, Client, Event, EventListener, Railtie, TestClient

Constant Summary collapse

VERSION =
'1.4.7'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#client_optionsHash

Returns client specific options.

Returns:

  • (Hash)

    client specific options



34
35
36
# File 'lib/isimud.rb', line 34

config_accessor :client_type do
  :bunny
end

#client_typeEnumerable<'bunny', 'test'>

Returns Type of client to use.

Returns:

  • (Enumerable<'bunny', 'test'>)

    Type of client to use



34
35
36
# File 'lib/isimud.rb', line 34

config_accessor :client_type do
  :bunny
end

#default_clientIsimud::Client

Returns default client.

Returns:



34
35
36
# File 'lib/isimud.rb', line 34

config_accessor :client_type do
  :bunny
end

#enable_model_watcherBoolean

Returns when set, send Isimud::ModelWatcher messages.

Returns:

  • (Boolean)

    when set, send Isimud::ModelWatcher messages



34
35
36
# File 'lib/isimud.rb', line 34

config_accessor :client_type do
  :bunny
end

#events_exchangeString

Returns AMQP exchange used for publishing Event instances.

Returns:

  • (String)

    AMQP exchange used for publishing Event instances



34
35
36
# File 'lib/isimud.rb', line 34

config_accessor :client_type do
  :bunny
end

#listener_error_limitInteger

Returns maximum number of uncaught exceptions allowed per hour before listener shuts down (100).

Returns:

  • (Integer)

    maximum number of uncaught exceptions allowed per hour before listener shuts down (100)



34
35
36
# File 'lib/isimud.rb', line 34

config_accessor :client_type do
  :bunny
end

#log_levelSymbol

Returns log level (:debug).

Returns:

  • (Symbol)

    log level (:debug)



34
35
36
# File 'lib/isimud.rb', line 34

config_accessor :client_type do
  :bunny
end

#loggerLogger

Returns logger for tracing messages (Rails.logger).

Returns:

  • (Logger)

    logger for tracing messages (Rails.logger)



34
35
36
# File 'lib/isimud.rb', line 34

config_accessor :client_type do
  :bunny
end

#model_watcher_exchangeString

Returns AMQP exchange used for publishing ModelWatcher messages.

Returns:

  • (String)

    AMQP exchange used for publishing ModelWatcher messages



34
35
36
# File 'lib/isimud.rb', line 34

config_accessor :client_type do
  :bunny
end

#model_watcher_schemaString

Returns schema name (Rails.configuration.database_configuration[‘database’]).

Returns:



34
35
36
# File 'lib/isimud.rb', line 34

config_accessor :client_type do
  :bunny
end

#prefetch_countInteger

Returns number of messages to fetch – only applies to BunnyClient.

Returns:

  • (Integer)

    number of messages to fetch – only applies to BunnyClient



34
35
36
# File 'lib/isimud.rb', line 34

config_accessor :client_type do
  :bunny
end

#retry_failuresBoolean|nil

When set to nil, the return status from exception handlers is used. (false)

Returns:

  • (Boolean|nil)

    whether to requeue a message if an exception occurs during processing.

See Also:



34
35
36
# File 'lib/isimud.rb', line 34

config_accessor :client_type do
  :bunny
end

#server<String, Hash>

Returns server connection attributes ().

Returns:

  • (<String, Hash>)

    server connection attributes ()



34
35
36
# File 'lib/isimud.rb', line 34

config_accessor :client_type do
  :bunny
end

Class Method Details

.clientIsimud::Client

Fetch or initialize the messaging client for this process.

Returns:



70
71
72
# File 'lib/isimud.rb', line 70

def self.client
  self.default_client ||= client_class.new(server, client_options || {})
end

.client_classObject



63
64
65
66
# File 'lib/isimud.rb', line 63

def self.client_class
  type = "#{client_type}_client".classify
  "Isimud::#{type}".constantize
end

.connectObject

Connect to the messaging server



75
76
77
# File 'lib/isimud.rb', line 75

def self.connect
  client.connect
end

.model_watcher_enabled?Boolean

Return status of model watching mode

Returns:

  • (Boolean)


80
81
82
# File 'lib/isimud.rb', line 80

def self.model_watcher_enabled?
  enable_model_watcher.nil? || enable_model_watcher
end

.reconnectObject

Reconnect the messaging client



85
86
87
# File 'lib/isimud.rb', line 85

def self.reconnect
  client.reconnect
end