Class: SidekiqUniqueJobs::Script::Client
- Inherits:
-
Object
- Object
- SidekiqUniqueJobs::Script::Client
- Includes:
- Timing
- Defined in:
- lib/sidekiq_unique_jobs/script/client.rb
Overview
Interface to dealing with .lua files
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#file_name ⇒ String
readonly
The name of the file to execute.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#scripts ⇒ Object
readonly
Returns the value of attribute scripts.
Instance Method Summary collapse
-
#execute(script_name, conn, keys: [], argv: []) ⇒ Object
Execute a lua script with the provided script_name.
-
#initialize(config) ⇒ Client
constructor
A new instance of Client.
Methods included from Timing
Constructor Details
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
18 19 20 |
# File 'lib/sidekiq_unique_jobs/script/client.rb', line 18 def config @config end |
#file_name ⇒ String (readonly)
Returns The name of the file to execute.
18 |
# File 'lib/sidekiq_unique_jobs/script/client.rb', line 18 attr_reader :config |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
14 15 16 |
# File 'lib/sidekiq_unique_jobs/script/client.rb', line 14 def logger @logger end |
#scripts ⇒ Object (readonly)
Returns the value of attribute scripts.
22 23 24 |
# File 'lib/sidekiq_unique_jobs/script/client.rb', line 22 def scripts @scripts end |
Instance Method Details
#execute(script_name, conn, keys: [], argv: []) ⇒ Object
Note:
this method is recursive if we need to load a lua script that wasn’t previously loaded.
Execute a lua script with the provided script_name
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/sidekiq_unique_jobs/script/client.rb', line 43 def execute(script_name, conn, keys: [], argv: []) result, elapsed = timed do scripts.execute(script_name, conn, keys: keys, argv: argv) end logger.debug("Executed #{script_name}.lua in #{elapsed}ms") result rescue ::RedisClient::CommandError => ex handle_error(script_name, conn, ex) do execute(script_name, conn, keys: keys, argv: argv) end end |