td-client 0.8.9 → 0.8.10
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +7 -0
- data/lib/td/client.rb +17 -6
- data/lib/td/client/api.rb +31 -4
- data/lib/td/client/model.rb +16 -4
- data/lib/td/client/version.rb +1 -1
- metadata +8 -8
data/ChangeLog
CHANGED
@@ -1,4 +1,11 @@
|
|
1
1
|
|
2
|
+
== 2012-02-22 version 0.8.10
|
3
|
+
|
4
|
+
* Added Client#run_schedule and update_schedule
|
5
|
+
* Added timezone, delay and next_time fields to the Schedule model
|
6
|
+
* create_aggregation_schema accepts params argument
|
7
|
+
|
8
|
+
|
2
9
|
== 2012-02-12 version 0.8.9
|
3
10
|
|
4
11
|
* Added API#normalize_table_name and API#normalize_database_name
|
data/lib/td/client.rb
CHANGED
@@ -169,12 +169,17 @@ class Client
|
|
169
169
|
# [Schedule]
|
170
170
|
def schedules
|
171
171
|
result = @api.list_schedules
|
172
|
-
result.map {|name,cron,query,database,rset|
|
172
|
+
result.map {|name,cron,query,database,rset,timezone,delay,next_time|
|
173
173
|
rset = ResultSet.new(self, rset) if rset
|
174
|
-
Schedule.new(self, name, cron, query, database, rset)
|
174
|
+
Schedule.new(self, name, cron, query, database, rset, timezone, delay, next_time)
|
175
175
|
}
|
176
176
|
end
|
177
177
|
|
178
|
+
def update_schedule(name, params)
|
179
|
+
@api.update_schedule(name, params)
|
180
|
+
nil
|
181
|
+
end
|
182
|
+
|
178
183
|
# [ScheduledJob]
|
179
184
|
def history(name, from=nil, to=nil)
|
180
185
|
result = @api.history(name, from, to)
|
@@ -184,6 +189,12 @@ class Client
|
|
184
189
|
}
|
185
190
|
end
|
186
191
|
|
192
|
+
# TODO nil -> [ScheduledJob] or [Job]
|
193
|
+
def run_schedule(name, time, num)
|
194
|
+
@api.run_schedule(name, time, num)
|
195
|
+
nil
|
196
|
+
end
|
197
|
+
|
187
198
|
# => time:Flaot
|
188
199
|
def import(db_name, table_name, format, stream, size)
|
189
200
|
@api.import(db_name, table_name, format, stream, size)
|
@@ -218,14 +229,14 @@ class Client
|
|
218
229
|
# => [AggregationSchema]
|
219
230
|
def aggregation_schemas
|
220
231
|
list = @api.list_aggregation_schema
|
221
|
-
list.map {|name,relation_key|
|
222
|
-
AggregationSchema.new(self, name, relation_key)
|
232
|
+
list.map {|name,relation_key,timezone|
|
233
|
+
AggregationSchema.new(self, name, relation_key, nil, nil, timezone)
|
223
234
|
}
|
224
235
|
end
|
225
236
|
|
226
237
|
# => true
|
227
|
-
def create_aggregation_schema(name, relation_key)
|
228
|
-
@api.create_aggregation_schema(name, relation_key)
|
238
|
+
def create_aggregation_schema(name, relation_key, params={})
|
239
|
+
@api.create_aggregation_schema(name, relation_key, params)
|
229
240
|
end
|
230
241
|
|
231
242
|
# => true
|
data/lib/td/client/api.rb
CHANGED
@@ -410,11 +410,22 @@ class API
|
|
410
410
|
query = m['query']
|
411
411
|
database = m['database']
|
412
412
|
rset = m['result']
|
413
|
-
|
413
|
+
timezone = m['timezone']
|
414
|
+
delay = m['delay']
|
415
|
+
next_time = m['next_time']
|
416
|
+
result << [name, cron, query, database, rset, timezone, delay, next_time]
|
414
417
|
}
|
415
418
|
return result
|
416
419
|
end
|
417
420
|
|
421
|
+
def update_schedule(name, params)
|
422
|
+
code, body, res = get("/v3/schedule/update/#{e name}", params)
|
423
|
+
if code != "200"
|
424
|
+
raise_error("Update schedule failed", res)
|
425
|
+
end
|
426
|
+
return nil
|
427
|
+
end
|
428
|
+
|
418
429
|
def history(name, from=0, to=nil)
|
419
430
|
params = {}
|
420
431
|
params['from'] = from.to_s if from
|
@@ -439,6 +450,22 @@ class API
|
|
439
450
|
return result
|
440
451
|
end
|
441
452
|
|
453
|
+
def run_schedule(name, time, num)
|
454
|
+
params = {}
|
455
|
+
params = {'num' => num} if num
|
456
|
+
code, body, res = post("/v3/schedule/run/#{e name}/#{e time}", params)
|
457
|
+
if code != "200"
|
458
|
+
raise_error("Run schedule failed", res)
|
459
|
+
end
|
460
|
+
js = checked_json(body, %w[jobs])
|
461
|
+
result = []
|
462
|
+
js['jobs'].each {|m|
|
463
|
+
job_id = m['job_id']
|
464
|
+
scheduled_at = m['scheduled_at']
|
465
|
+
result << [job_id, scheduled_at]
|
466
|
+
}
|
467
|
+
return result
|
468
|
+
end
|
442
469
|
|
443
470
|
####
|
444
471
|
## Import API
|
@@ -516,14 +543,14 @@ class API
|
|
516
543
|
result = js["aggrs"].map {|aggrinfo|
|
517
544
|
name = aggrinfo['name'].to_s
|
518
545
|
relation_key = aggrinfo['relation_key'].to_s
|
519
|
-
[
|
546
|
+
timezone = aggrinfo['timezone'].to_s
|
547
|
+
[name, relation_key, timezone]
|
520
548
|
}
|
521
549
|
return result
|
522
550
|
end
|
523
551
|
|
524
552
|
# => true
|
525
|
-
def create_aggregation_schema(name, relation_key)
|
526
|
-
params = {}
|
553
|
+
def create_aggregation_schema(name, relation_key, params={})
|
527
554
|
params['relation_key'] = relation_key if relation_key
|
528
555
|
code, body, res = post("/v3/aggr/create/#{e name}", params)
|
529
556
|
if code != "200"
|
data/lib/td/client/model.rb
CHANGED
@@ -282,20 +282,31 @@ end
|
|
282
282
|
|
283
283
|
|
284
284
|
class Schedule < Model
|
285
|
-
def initialize(client, name, cron, query, database=nil, rset=nil)
|
285
|
+
def initialize(client, name, cron, query, database=nil, rset=nil, timezone=nil, delay=nil, next_time=nil)
|
286
286
|
super(client)
|
287
287
|
@name = name
|
288
288
|
@cron = cron
|
289
289
|
@query = query
|
290
290
|
@database = database
|
291
291
|
@rset = rset
|
292
|
+
@timezone = timezone
|
293
|
+
@delay = delay
|
294
|
+
@next_time = next_time
|
292
295
|
end
|
293
296
|
|
294
297
|
def rset_name
|
295
298
|
@rset ? @rset.name : nil
|
296
299
|
end
|
297
300
|
|
298
|
-
attr_reader :name, :cron, :query, :database, :rset
|
301
|
+
attr_reader :name, :cron, :query, :database, :rset, :timezone, :delay
|
302
|
+
|
303
|
+
def next_time
|
304
|
+
@next_time ? Time.parse(@next_time) : nil
|
305
|
+
end
|
306
|
+
|
307
|
+
def run(time, num)
|
308
|
+
@client.run_schedule(time, num)
|
309
|
+
end
|
299
310
|
end
|
300
311
|
|
301
312
|
|
@@ -325,15 +336,16 @@ end
|
|
325
336
|
|
326
337
|
|
327
338
|
class AggregationSchema < Model
|
328
|
-
def initialize(client, name, relation_key, logs=nil, attributes=nil)
|
339
|
+
def initialize(client, name, relation_key, logs=nil, attributes=nil, timezone=nil)
|
329
340
|
super(client)
|
330
341
|
@name = name
|
331
342
|
@relation_key = relation_key
|
332
343
|
@logs = logs
|
333
344
|
@attributes = attributes
|
345
|
+
@timezone = timezone
|
334
346
|
end
|
335
347
|
|
336
|
-
attr_reader :name, :relation_key
|
348
|
+
attr_reader :name, :relation_key, :timezone
|
337
349
|
|
338
350
|
def logs
|
339
351
|
update_entries! unless @logs
|
data/lib/td/client/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: td-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-23 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: msgpack
|
16
|
-
requirement: &
|
16
|
+
requirement: &70267150692160 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.4.4
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70267150692160
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: json
|
27
|
-
requirement: &
|
27
|
+
requirement: &70267150691460 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.4.3
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70267150691460
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70267150690860 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: 2.8.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70267150690860
|
47
47
|
description:
|
48
48
|
email:
|
49
49
|
executables: []
|