Class: SplitIoClient::SSE::NotificationManagerKeeper

Inherits:
Object
  • Object
show all
Defined in:
lib/splitclient-rb/sse/notification_manager_keeper.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) {|_self| ... } ⇒ NotificationManagerKeeper

Returns a new instance of NotificationManagerKeeper.

Yields:

  • (_self)

Yield Parameters:



8
9
10
11
12
13
14
# File 'lib/splitclient-rb/sse/notification_manager_keeper.rb', line 8

def initialize(config)
  @config = config
  @publisher_available = Concurrent::AtomicBoolean.new(true)
  @on = { occupancy: ->(_) {}, push_shutdown: ->(_) {} }

  yield self if block_given?
end

Instance Method Details

#handle_incoming_occupancy_event(event) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/splitclient-rb/sse/notification_manager_keeper.rb', line 16

def handle_incoming_occupancy_event(event)
  if event.data['type'] == 'CONTROL'
    process_event_control(event.data['controlType'])
  elsif event.channel == SplitIoClient::Constants::CONTROL_PRI
    process_event_occupancy(event.data['metrics']['publishers'])
  end
rescue StandardError => e
  @config.logger.error(e)
end

#on_occupancy(&action) ⇒ Object



26
27
28
# File 'lib/splitclient-rb/sse/notification_manager_keeper.rb', line 26

def on_occupancy(&action)
  @on[:occupancy] = action
end

#on_push_shutdown(&action) ⇒ Object



30
31
32
# File 'lib/splitclient-rb/sse/notification_manager_keeper.rb', line 30

def on_push_shutdown(&action)
  @on[:push_shutdown] = action
end