Class: RQ::Executor
- Inherits:
-
MainHelper
- Object
- MainHelper
- RQ::Executor
- Defined in:
- lib/rq/executor.rb
Overview
the Executor is for expert use only and executes arbitrary sql on the queue’s db. the reason one should not do this directly with the sqlite command line program is that it will not respect the locking subsystem used in RQ - the Executor method will
Constant Summary
Constants included from Logging
Logging::DIV0, Logging::DIV1, Logging::DIV2, Logging::DIV3, Logging::EOL, Logging::SEC0, Logging::SEC1, Logging::SEC2, Logging::SEC3
Instance Attribute Summary
Attributes inherited from MainHelper
#argv, #cmd, #dot_rq_dir, #env, #fields, #job_stdin, #loops, #main, #mode, #options, #program, #q, #qpath, #quiet, #stdin
Instance Method Summary collapse
-
#execute ⇒ Object
–{{{.
Methods inherited from MainHelper
#dumping_yaml_tuples, #field_match, #init_job_stdin!, #initialize, #loadio, #loadyaml, #set_q
Methods included from Logging
Methods included from Logging::LogMethods
#debug, #error, #fatal, #info, #logerr, #logger, #logger=, #warn
Methods included from Util
#alive?, append_features, #btrace, #columnize, #defval, #emsg, #erreq, #errmsg, #escape, #escape!, #exec, export, #fork, #getopt, #hashify, #hms, #host, #hostname, #klass, #maim, #mcp, #realpath, #stamptime, #system, #timestamp, #tmpnam, #uncache, #which_ruby
Constructor Details
This class inherits a constructor from RQ::MainHelper
Instance Method Details
#execute ⇒ Object
–{{{
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rq/executor.rb', line 17 def execute #--{{{ set_q sql = @argv.join ' ' if sql.empty? and stdin? debug{ "reading sql from stdin" } while((buf = stdin.gets)) buf.strip! buf.gsub! %r/#.*$/o, '' next if buf.empty? sql << "#{ buf } " end end abort "no sql to execute" if sql.empty? @q.qdb.transaction_retries = 0 @q.transaction{@q.execute(sql, &dumping_yaml_tuples)} #--}}} end |