Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add queue_name configuration #9

Merged
merged 1 commit into from
Jun 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ $ gem install nexaas-async-collector
# The namespace where you want to store you data within Redis
config.redis_namespace = 'nexaas_async'

# The name of the sidekiq queue to be used
config.queue_name = :high_fast

# The method that returns the user object (or any other object you want. It must respond to id method)
config.scope = :current_user

Expand Down
2 changes: 1 addition & 1 deletion app/workers/nexaas/async/collector/async_resource_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Collector
class AsyncResourceJob

include Sidekiq::Worker
sidekiq_options queue: :high_fast
sidekiq_options queue: Nexaas::Async::Collector.queue_name

def perform(collector_id, user_id, klass_name, klass_method, args=[])
content = call_for_method(klass_name, klass_method, args)
Expand Down
4 changes: 4 additions & 0 deletions lib/nexaas/async/collector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ module Collector
mattr_accessor :redis_namespace
@@redis_namespace = 'nexaas_async'

# Name of the sidekiq queue to be used
mattr_accessor :queue_name
@@queue_name = :high_fast

# Method will be called to get the user/account id
# This ID is used to store and ensure only the user
# will fetch the processed data.
Expand Down
6 changes: 6 additions & 0 deletions spec/lib/nexaas/async/collector_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
it { expect(described_class.redis_namespace).to eq('nexaas_async') }
end

describe '.queue_name' do
it { expect(described_class.queue_name).to eq(:high_fast) }
end

describe '.scope' do
it { expect(described_class.scope).to eq('current_user') }
end
Expand All @@ -26,10 +30,12 @@
described_class.configure do |c|
c.redis_url = 'anything'
c.redis_namespace = 'specific_namespace'
c.queue_name = 'faster'
end

expect(described_class.redis_url).to eq('anything')
expect(described_class.redis_namespace).to eq('specific_namespace')
expect(described_class.queue_name).to eq('faster')
end
end
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require "rails_helper"
require 'rails_helper'
require 'sidekiq/testing'

class DummyModel
def self.generate(first_arg, second_arg)
Expand All @@ -13,6 +14,10 @@ def self.update
describe Nexaas::Async::Collector::AsyncResourceJob do
subject { described_class.new }

it 'uses the correct queue name' do
expect { described_class.perform_async }.to change(Sidekiq::Queues['high_fast'], :size).by(1)
end

describe "#perform" do
context "when there are additional args" do
it 'invokes Persist.save' do
Expand Down