Class: SplitIoClient::Cache::Senders::ImpressionsSender

Inherits:
Object
  • Object
show all
Defined in:
lib/splitclient-rb/cache/senders/impressions_sender.rb

Instance Method Summary collapse

Constructor Details

#initialize(impressions_repository, config, api_key) ⇒ ImpressionsSender

Returns a new instance of ImpressionsSender.



5
6
7
8
9
# File 'lib/splitclient-rb/cache/senders/impressions_sender.rb', line 5

def initialize(impressions_repository, config, api_key)
  @impressions_repository = impressions_repository
  @config = config
  @api_key = api_key
end

Instance Method Details

#callObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/splitclient-rb/cache/senders/impressions_sender.rb', line 11

def call
  # Disable impressions if @config.impressions_queue_size == -1
  if @config.impressions_queue_size < 0
    @config.logger.info('Disabling impressions service by config')
    return
  end

  if ENV['SPLITCLIENT_ENV'] == 'test'
    post_impressions
  else
    impressions_thread

    if defined?(PhusionPassenger)
      PhusionPassenger.on_event(:starting_worker_process) do |forked|
        impressions_thread if forked
      end
    end
  end
end