-
-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactorize connectors to use them in client and server
- Loading branch information
Showing
12 changed files
with
87 additions
and
117 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,16 @@ | ||
require 'sidekiq-unique-jobs/connectors/testing' | ||
require 'sidekiq-unique-jobs/connectors/redis_pool' | ||
require 'sidekiq-unique-jobs/connectors/sidekiq_redis' | ||
|
||
module SidekiqUniqueJobs | ||
module Connectors | ||
ConnectorTypes= [Testing, RedisPool, SidekiqRedis] | ||
|
||
def self.conn(redis_pool = nil) | ||
ConnectorTypes.each do |connector| | ||
conn = connector.conn(redis_pool) | ||
return conn if conn | ||
end | ||
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,10 @@ | ||
module SidekiqUniqueJobs | ||
module Connectors | ||
class RedisPool | ||
def self.conn(redis_pool = nil) | ||
return if redis_pool.nil? | ||
redis_pool.with { |conn| conn } | ||
end | ||
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 @@ | ||
module SidekiqUniqueJobs | ||
module Connectors | ||
class SidekiqRedis | ||
def self.conn(redis_pool = nil) | ||
Sidekiq.redis { |conn| conn } | ||
end | ||
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,10 @@ | ||
module SidekiqUniqueJobs | ||
module Connectors | ||
class Testing | ||
def self.conn(redis_pool = nil) | ||
return unless Config.testing_enabled? | ||
SidekiqUniqueJobs.redis_mock { |conn| conn } | ||
end | ||
end | ||
end | ||
end |
21 changes: 0 additions & 21 deletions
21
lib/sidekiq-unique-jobs/middleware/client/connectors/redis_pool.rb
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
lib/sidekiq-unique-jobs/middleware/client/connectors/sidekiq_redis.rb
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
lib/sidekiq-unique-jobs/middleware/client/connectors/testing_fake.rb
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
lib/sidekiq-unique-jobs/middleware/client/connectors/testing_inline.rb
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
lib/sidekiq-unique-jobs/middleware/client/strategies/testing_inline.rb
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,21 @@ | ||
require 'sidekiq-unique-jobs/middleware/server/unique_jobs' | ||
|
||
module SidekiqUniqueJobs | ||
module Middleware | ||
module Client | ||
module Strategies | ||
class TestingInline < Unique | ||
def self.elegible? | ||
Config.testing_enabled? && Sidekiq::Testing.inline? | ||
end | ||
|
||
def review | ||
SidekiqUniqueJobs::Middleware::Server::UniqueJobs.new.call(worker_class.new, item, queue, redis_pool) do | ||
super | ||
end | ||
end | ||
end | ||
end | ||
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
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