Module: Mongo::Monitoring::Global

Extended by:
Global
Included in:
Global
Defined in:
lib/mongo/monitoring.rb

Overview

Provides behaviour around global subscribers.

Since:

  • 2.1.0

Instance Method Summary collapse

Instance Method Details

#subscribe(topic, subscriber) ⇒ Object

Subscribe a listener to an event topic.

Examples:

Subscribe to the topic.

Monitoring::Global.subscribe(QUERY, subscriber)

Parameters:

  • topic (String)

    The event topic.

  • subscriber (Object)

    The subscriber to handle the event.

Since:

  • 2.1.0



99
100
101
# File 'lib/mongo/monitoring.rb', line 99

def subscribe(topic, subscriber)
  subscribers_for(topic).push(subscriber)
end

#subscribersHash<String, Object>

Get all the global subscribers.

Examples:

Get all the global subscribers.

Monitoring::Global.subscribers

Returns:

  • (Hash<String, Object>)

    The subscribers.

Since:

  • 2.1.0



111
112
113
# File 'lib/mongo/monitoring.rb', line 111

def subscribers
  @subscribers ||= {}
end