Skip to content

Commit

Permalink
Gluing the stack on sidekiq
Browse files Browse the repository at this point in the history
  • Loading branch information
nviennot committed Apr 20, 2013
1 parent 44e6778 commit 62065d6
Show file tree
Hide file tree
Showing 21 changed files with 84 additions and 413 deletions.
2 changes: 1 addition & 1 deletion Procfile
@@ -1,2 +1,2 @@
unicorn: bundle exec unicorn -p 3000 -c ./config/unicorn.rb
sidekiq: bundle exec sidekiq -v -q apk_decompiler -q apk_downloader -q app_query_fetcher,10 -q app_query_dispatcher,10 -c 10
sidekiq: bundle exec sidekiq -v -q search_app -q process_app,20 -t 60 -c 10
11 changes: 7 additions & 4 deletions app/models/app.rb
Expand Up @@ -75,11 +75,14 @@ def self.from_market(app)
raise ParseError.new "#{e.class}: #{e}\n#{app.inspect}"
end

def repo(options={})
Repository.new(self.id, options)
def self.discovered_app(app_id)
if Redis.instance.sadd('apps', app_id)
# New app!
ProcessApp.perform_async(app_id)
end
end

def id_version
@id_version ||= "#{id}-#{version_code}"
def self.discovered_apps(app_ids)
app_ids.each { |app_id| discovered_app(app_id) }
end
end
74 changes: 0 additions & 74 deletions app/models/lib.rb

This file was deleted.

4 changes: 3 additions & 1 deletion app/models/repository.rb
Expand Up @@ -6,7 +6,9 @@ class EmptyCommit < RuntimeError; end

# Rugged gets its hands on new, not initialize
def self.new(app_id, options={})
path = REPO_PATH.join(*app_id.split('.'))
componants = app_id.split('.')
componants.last << '.git'
path = REPO_PATH.join(*componants)

if options[:auto_create] && !path.exist?
init_at(path.to_s, :bare)
Expand Down
79 changes: 0 additions & 79 deletions app/models/source.rb

This file was deleted.

27 changes: 0 additions & 27 deletions app/worker/apk_core_finder.rb

This file was deleted.

26 changes: 0 additions & 26 deletions app/worker/apk_core_writer.rb

This file was deleted.

31 changes: 0 additions & 31 deletions app/worker/apk_decompiler.rb

This file was deleted.

25 changes: 0 additions & 25 deletions app/worker/app_query_dispatcher.rb

This file was deleted.

27 changes: 0 additions & 27 deletions app/worker/app_query_fetcher.rb

This file was deleted.

32 changes: 0 additions & 32 deletions app/worker/lib_finder.rb

This file was deleted.

8 changes: 8 additions & 0 deletions app/worker/process_app.rb
@@ -0,0 +1,8 @@
class ProcessApp
include Sidekiq::Worker
sidekiq_options :queue => name.underscore, :backtrace => true

def perform(app_id)
Stack.process_app(app_id)
end
end
13 changes: 13 additions & 0 deletions app/worker/search_app.rb
@@ -0,0 +1,13 @@
class SearchApp
include Sidekiq::Worker
sidekiq_options :queue => name.underscore, :backtrace => true

def perform(app_id, raw_url=nil)
results = Market.search(app_id, :raw_url => raw_url)
App.discovered_apps(results.app_ids)

if results.next_page_url
self.class.perform_async(app_id, results.next_page_url)
end
end
end
2 changes: 1 addition & 1 deletion config/unicorn.rb
Expand Up @@ -69,6 +69,6 @@
Redis.instance.client.connect

Sidekiq.configure_client do |config|
config.redis = { :url => Redis.instance.client.id, :namespace => 'google-play-crawler' }
config.redis = { :url => Redis.instance.client.id }
end
end

0 comments on commit 62065d6

Please sign in to comment.