Permalink
Browse files

added Client#run_schedule

  • Loading branch information...
1 parent 1d18905 commit 943cf705994439835168d29c26b9341e199ad769 @frsyuki frsyuki committed Feb 11, 2012
Showing with 26 additions and 0 deletions.
  1. +6 −0 lib/td/client.rb
  2. +16 −0 lib/td/client/api.rb
  3. +4 −0 lib/td/client/model.rb
View
@@ -184,6 +184,12 @@ def history(name, from=nil, to=nil)
}
end
+ # TODO nil -> [ScheduledJob] or [Job]
+ def run_schedule(name, time, num)
+ @api.run_schedule(name, time, num)
+ nil
+ end
+
# => time:Flaot
def import(db_name, table_name, format, stream, size)
@api.import(db_name, table_name, format, stream, size)
View
@@ -422,6 +422,22 @@ def history(name, from=0, to=nil)
return result
end
+ def run_schedule(name, time, num)
+ params = {}
+ params = {'num' => num} if num
+ code, body, res = post("/v3/schedule/run/#{e name}/#{e time}", params)
+ if code != "200"
+ raise_error("Run schedule failed", res)
+ end
+ js = checked_json(body, %w[jobs])
+ result = []
+ js['jobs'].each {|m|
+ job_id = m['job_id']
+ scheduled_at = m['scheduled_at']
+ result << [job_id, scheduled_at]
+ }
+ return result
+ end
####
## Import API
@@ -303,6 +303,10 @@ def rset_name
def next_time
@next_time ? Time.parse(@next_time) : nil
end
+
+ def run(time, num)
+ @client.run_schedule(time, num)
+ end
end

0 comments on commit 943cf70

Please sign in to comment.