-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using sidekiq to process transactions and event logs.
- Loading branch information
1 parent
9928eb7
commit 7c80caf
Showing
23 changed files
with
179 additions
and
60 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
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
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
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,14 @@ | ||
# frozen_string_literal: true | ||
|
||
class SaveErc20TransferWorker | ||
include Sidekiq::Worker | ||
|
||
def perform(event_log_id) | ||
event_log = EventLog.find_by(id: event_log_id) | ||
return if event_log.nil? | ||
|
||
if Erc20Transfer.exists?(address: event_log.address&.downcase) && Erc20Transfer.transfer?(event_log.topics) | ||
Erc20Transfer.save_from_event_log(event_log) | ||
end | ||
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,9 @@ | ||
# frozen_string_literal: true | ||
|
||
class SaveEventLogsWorker | ||
include Sidekiq::Worker | ||
|
||
def perform(logs) | ||
CitaSync::Persist.save_event_logs(logs) | ||
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,9 @@ | ||
# frozen_string_literal: true | ||
|
||
class SaveTransactionWorker | ||
include Sidekiq::Worker | ||
|
||
def perform(hash) | ||
CitaSync::Persist.save_transaction(hash) | ||
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
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 @@ | ||
# frozen_string_literal: true | ||
|
||
require "redis" | ||
require "redis/objects" | ||
|
||
redis_config = Rails.application.config_for(:redis) | ||
|
||
$redis = Redis.new(url: redis_config["url"], driver: :hiredis, password: redis_config["password"]) | ||
Redis::Objects.redis = $redis |
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 @@ | ||
redis_config = Rails.application.config_for(:redis) | ||
sidekiq_url = redis_config["url"] | ||
redis_password = redis_config["password"] | ||
|
||
namespace = ENV.fetch("REDIS_NAMESPACE") { "rebirth" } | ||
|
||
Sidekiq.configure_server do |config| | ||
config.redis = { url: sidekiq_url, driver: :hiredis, password: redis_password, namespace: namespace } | ||
end | ||
Sidekiq.configure_client do |config| | ||
config.redis = { url: sidekiq_url, driver: :hiredis, password: redis_password, namespace: namespace } | ||
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,12 @@ | ||
defaults: &defaults | ||
url: <%= ENV.fetch("REDIS_URL") || "redis://localhost:6379/8" %> | ||
password: <%= ENV["REDIS_PASSWORD"] %> | ||
|
||
development: | ||
<<: *defaults | ||
|
||
test: | ||
<<: *defaults | ||
|
||
production: | ||
<<: *defaults |
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,6 @@ | ||
--- | ||
:concurrency: <%= ENV["SIDEKIQ_THREADS"]&.to_i || 25 %> | ||
:pidfile: tmp/pids/sidekiq.pid | ||
:logfile: log/sidekiq.log | ||
:queues: | ||
- [default, 1] |
Oops, something went wrong.