A Sidekiq::Worker gets triggered with the endpoint class and the params.
class Wrappi::AsyncRequestWorker
include Sidekiq::Worker
def perform(endpoint_class, params = {}, opts = {})
inst = endpoint_class.constantize.new(params)
if inst.success?
inst.perform_async_callback(opts)
end
end
end
An async callback in the endpoint config receives the response and executes the code in the block
class User < Wrappi::Endpoint
async_callback do |endpoint|
# do something here
end
end
add to endpoint a way to perform requests async