-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement asynchronous account synchronization with Sidekiq and add i…
…nitial configuration
- Loading branch information
Showing
6 changed files
with
72 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"cron": [ | ||
{ | ||
"command": "bundle exec rake accounts:sync_least_recent", | ||
"schedule": "0 * * * *" | ||
}, | ||
{ | ||
"command": "bundle exec rake accounts:import_from_repos", | ||
"schedule": "0 0 * * *" | ||
} | ||
] | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class AccountWorker | ||
include Sidekiq::Worker | ||
|
||
sidekiq_options queue: 'default', lock: :until_executed, lock_expiration: 1.hours.to_i | ||
|
||
def perform(account_id) | ||
Account.find_by_id(account_id).try(:sync_all) | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Sidekiq.configure_server do |config| | ||
config.redis = { ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE } } | ||
|
||
config.client_middleware do |chain| | ||
chain.add SidekiqUniqueJobs::Middleware::Client | ||
end | ||
|
||
config.server_middleware do |chain| | ||
chain.add SidekiqUniqueJobs::Middleware::Server | ||
end | ||
|
||
SidekiqUniqueJobs::Server.configure(config) | ||
end | ||
|
||
Sidekiq.configure_client do |config| | ||
config.logger = Rails.logger if Rails.env.test? | ||
config.redis = { ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE } } | ||
|
||
config.client_middleware do |chain| | ||
chain.add SidekiqUniqueJobs::Middleware::Client | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
:concurrency: 1 | ||
:queues: | ||
- default |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace :accounts do | ||
task sync_least_recent: :environment do | ||
Account.sync_least_recently_synced | ||
end | ||
|
||
task import_from_repos: :environment do | ||
Account.import_from_repos | ||
end | ||
end |