Sha256: 9b9e70c333c38fef32d090b87581396a115d3b12650f1fd257ff86d56cf6619b

Contents?: true

Size: 1.11 KB

Versions: 146

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module SplitIoClient
  module Cache
    module Senders
      class EventsSender
        def initialize(events_repository, config)
          @events_repository = events_repository
          @config = config
        end

        def call          
          events_thread

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

        private

        def events_thread
          @config.threads[:events_sender] = Thread.new do
            begin
              @config.logger.info('Starting events service')

              loop do
                post_events

                sleep(SplitIoClient::Utilities.randomize_interval(@config.events_push_rate))
              end
            rescue SplitIoClient::SDKShutdownException
              post_events

              @config.logger.info('Posting events due to shutdown')
            end
          end
        end

        def post_events
          @events_repository.post_events
        end
      end
    end
  end
end

Version data entries

146 entries across 146 versions & 1 rubygems

Version Path
splitclient-rb-7.3.3.pre.rc2-java lib/splitclient-rb/cache/senders/events_sender.rb
splitclient-rb-7.3.3.pre.rc2 lib/splitclient-rb/cache/senders/events_sender.rb
splitclient-rb-7.3.2-java lib/splitclient-rb/cache/senders/events_sender.rb
splitclient-rb-7.3.2 lib/splitclient-rb/cache/senders/events_sender.rb
splitclient-rb-7.3.2.pre.rc5-java lib/splitclient-rb/cache/senders/events_sender.rb
splitclient-rb-7.3.2.pre.rc5 lib/splitclient-rb/cache/senders/events_sender.rb
splitclient-rb-7.3.2.pre.rc4-java lib/splitclient-rb/cache/senders/events_sender.rb
splitclient-rb-7.3.2.pre.rc4 lib/splitclient-rb/cache/senders/events_sender.rb
splitclient-rb-7.3.2.pre.rc3-java lib/splitclient-rb/cache/senders/events_sender.rb
splitclient-rb-7.3.2.pre.rc3 lib/splitclient-rb/cache/senders/events_sender.rb
splitclient-rb-7.3.2.pre.rc2-java lib/splitclient-rb/cache/senders/events_sender.rb
splitclient-rb-7.3.2.pre.rc2 lib/splitclient-rb/cache/senders/events_sender.rb
splitclient-rb-7.3.2.pre.rc1-java lib/splitclient-rb/cache/senders/events_sender.rb
splitclient-rb-7.3.2.pre.rc1 lib/splitclient-rb/cache/senders/events_sender.rb
splitclient-rb-7.3.1-java lib/splitclient-rb/cache/senders/events_sender.rb
splitclient-rb-7.3.1 lib/splitclient-rb/cache/senders/events_sender.rb
splitclient-rb-7.3.1.pre.rc1-java lib/splitclient-rb/cache/senders/events_sender.rb
splitclient-rb-7.3.1.pre.rc1 lib/splitclient-rb/cache/senders/events_sender.rb
splitclient-rb-7.3.0-java lib/splitclient-rb/cache/senders/events_sender.rb
splitclient-rb-7.3.0 lib/splitclient-rb/cache/senders/events_sender.rb