Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Elixir/Sidekiq Pseudo Example
class StatsController
  def update
    # call sidekiq worker as normal
    TwitterStatsWorker.perform_async(twitter_user.pin, twitter_user.token)
  end
end

class TwitterStatsWorker
  include Sidekiq::Worker
  include ElixirKiq::Worker  # overrides perform_async to enqueue to Elixir's processor
  
  def perform(stats_results)
    # process stats results fetched by Elixir
  end

end
defmodule TwitterStatsWorker do
  use ElixirKiq.Worker
  
  def perform([pin, token]) do
    stats = # do some work fetching some twitter stats
    
    # enqueues *normal sikekiq* job back to Rails to be processed TwitterStatsWorker
    respond(stats)
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment