Module: Multiwoven::Integrations::Core::RateLimiter

Instance Method Summary collapse

Instance Method Details

#read(sync_config) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/multiwoven/integrations/core/rate_limiter.rb', line 18

def read(sync_config)
  stream = sync_config.stream

  @queue ||= Limiter::RateQueue.new(stream.request_rate_limit, interval: stream.rate_limit_unit_seconds) do
    Integrations::Service.logger.info("Hit the limit for stream: #{stream.name}, waiting")
  end

  @queue.shift

  super(sync_config)
end

#write(sync_config, records, action = "destination_insert") ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/multiwoven/integrations/core/rate_limiter.rb', line 6

def write(sync_config, records, action = "destination_insert")
  stream = sync_config.stream

  @queue ||= Limiter::RateQueue.new(stream.request_rate_limit, interval: stream.rate_limit_unit_seconds) do
    Integrations::Service.logger.info("Hit the limit for stream: #{stream.name}, waiting")
  end

  @queue.shift

  super(sync_config, records, action)
end