Created
July 28, 2018 13:47
-
-
Save manoelneto/6f780b3aea2455fcc26cfb604f95677b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "redis_batch_push" | |
require "redis" | |
require_relative "my_sidekiq_worker" | |
queue = "webhooks" | |
redis = Redis.new | |
# numero maximo de escuta por mensagens | |
max_interval_sec = 30 | |
# número máximo de mensagens a enviar de uma vez | |
max_size = 1000 | |
runner = RedisBatchPush::Runner.new(redis, queue, max_size, max_interval_sec) | |
runner.run do |data| | |
# como o webhooks_controller salva a mensagem em json, | |
# isso é um array de json, então devemos fazer o parser em cada | |
# mensagem | |
data = data.map do |d| | |
JSON.parse d | |
end | |
WebhookSidekiq.perform_async data.to_json | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment