Sha256: bb1932dd3264edb766469cf90776d7b12d047b6c0853aa649ab22058aea689be
Contents?: true
Size: 1.27 KB
Versions: 12
Compression:
Stored size: 1.27 KB
Contents
# frozen_string_literal: true module SplitIoClient module Cache module Senders class EventsSender def initialize(events_repository) @events_repository = events_repository end def call if ENV['SPLITCLIENT_ENV'] == 'test' post_events else events_thread if defined?(PhusionPassenger) PhusionPassenger.on_event(:starting_worker_process) do |forked| events_thread if forked end end end end private def events_thread SplitIoClient.configuration.threads[:events_sender] = Thread.new do begin SplitIoClient.configuration.logger.info('Starting events service') loop do post_events sleep(SplitIoClient::Utilities.randomize_interval(SplitIoClient.configuration.events_push_rate)) end rescue SplitIoClient::SDKShutdownException post_events SplitIoClient.configuration.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
12 entries across 12 versions & 1 rubygems