flockdb 0.5.1 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/flockdb.gemspec +8 -8
- data/lib/flock/client.rb +11 -5
- data/lib/flock/gen-rb/flock_d_b.rb +33 -33
- data/lib/flock/gen-rb/flockdb_types.rb +24 -24
- data/lib/flock/mock_service.rb +1 -2
- data/lib/flock/operations/execute_operation.rb +3 -2
- data/lib/flock/operations/execute_operations.rb +4 -3
- data/spec/execute_operations_spec.rb +26 -2
- data/spec/flock_spec.rb +9 -0
- data/spec/simple_operation_spec.rb +3 -2
- data/spec/spec_helper.rb +4 -2
- metadata +11 -11
data/Rakefile
CHANGED
|
@@ -22,8 +22,8 @@ begin
|
|
|
22
22
|
gemspec.email = "freels@twitter.com"
|
|
23
23
|
gemspec.homepage = "http://github.com/twitter/flockdb-client"
|
|
24
24
|
gemspec.authors = ["Matt Freels", "Rael Dornfest", "Nick Kallen"]
|
|
25
|
-
gemspec.add_dependency 'thrift', '>= 0.
|
|
26
|
-
gemspec.add_dependency 'thrift_client', '>= 0.
|
|
25
|
+
gemspec.add_dependency 'thrift', '>= 0.5.0'
|
|
26
|
+
gemspec.add_dependency 'thrift_client', '>= 0.6.0'
|
|
27
27
|
|
|
28
28
|
# development
|
|
29
29
|
gemspec.add_development_dependency 'rspec'
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.6.1
|
data/flockdb.gemspec
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = %q{flockdb}
|
|
8
|
-
s.version = "0.
|
|
8
|
+
s.version = "0.6.1"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Matt Freels", "Rael Dornfest", "Nick Kallen"]
|
|
12
|
-
s.date = %q{
|
|
12
|
+
s.date = %q{2011-02-28}
|
|
13
13
|
s.description = %q{Get your flock on in Ruby.}
|
|
14
14
|
s.email = %q{freels@twitter.com}
|
|
15
15
|
s.extra_rdoc_files = [
|
|
@@ -67,19 +67,19 @@ Gem::Specification.new do |s|
|
|
|
67
67
|
s.specification_version = 3
|
|
68
68
|
|
|
69
69
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
70
|
-
s.add_runtime_dependency(%q<thrift>, [">= 0.
|
|
71
|
-
s.add_runtime_dependency(%q<thrift_client>, [">= 0.
|
|
70
|
+
s.add_runtime_dependency(%q<thrift>, [">= 0.5.0"])
|
|
71
|
+
s.add_runtime_dependency(%q<thrift_client>, [">= 0.6.0"])
|
|
72
72
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
|
73
73
|
s.add_development_dependency(%q<rr>, [">= 0"])
|
|
74
74
|
else
|
|
75
|
-
s.add_dependency(%q<thrift>, [">= 0.
|
|
76
|
-
s.add_dependency(%q<thrift_client>, [">= 0.
|
|
75
|
+
s.add_dependency(%q<thrift>, [">= 0.5.0"])
|
|
76
|
+
s.add_dependency(%q<thrift_client>, [">= 0.6.0"])
|
|
77
77
|
s.add_dependency(%q<rspec>, [">= 0"])
|
|
78
78
|
s.add_dependency(%q<rr>, [">= 0"])
|
|
79
79
|
end
|
|
80
80
|
else
|
|
81
|
-
s.add_dependency(%q<thrift>, [">= 0.
|
|
82
|
-
s.add_dependency(%q<thrift_client>, [">= 0.
|
|
81
|
+
s.add_dependency(%q<thrift>, [">= 0.5.0"])
|
|
82
|
+
s.add_dependency(%q<thrift_client>, [">= 0.6.0"])
|
|
83
83
|
s.add_dependency(%q<rspec>, [">= 0"])
|
|
84
84
|
s.add_dependency(%q<rr>, [">= 0"])
|
|
85
85
|
end
|
data/lib/flock/client.rb
CHANGED
|
@@ -70,10 +70,13 @@ class Flock::Client
|
|
|
70
70
|
|
|
71
71
|
# edge manipulation
|
|
72
72
|
|
|
73
|
-
def update(method, source_id, graph, destination_id, priority = Flock::Priority::High)
|
|
73
|
+
def update(method, source_id, graph, destination_id, priority = Flock::Priority::High, options = {})
|
|
74
|
+
execute_at = options.delete(:execute_at)
|
|
75
|
+
position = options.delete(:position)
|
|
76
|
+
|
|
74
77
|
_cache_clear
|
|
75
|
-
ops = current_transaction || Flock::ExecuteOperations.new(@service, priority)
|
|
76
|
-
ops.send(method, *_query_args([source_id, graph, destination_id])[0, 3])
|
|
78
|
+
ops = current_transaction || Flock::ExecuteOperations.new(@service, priority, execute_at)
|
|
79
|
+
ops.send(method, *(_query_args([source_id, graph, destination_id])[0, 3] << position))
|
|
77
80
|
ops.apply unless in_transaction?
|
|
78
81
|
end
|
|
79
82
|
|
|
@@ -84,12 +87,15 @@ class Flock::Client
|
|
|
84
87
|
|
|
85
88
|
alias unarchive add
|
|
86
89
|
|
|
87
|
-
def transaction(priority = Flock::Priority::High, &block)
|
|
90
|
+
def transaction(priority = Flock::Priority::High, options = {}, &block)
|
|
91
|
+
execute_at = options.delete(:execute_at)
|
|
92
|
+
position = options.delete(:position)
|
|
93
|
+
|
|
88
94
|
new_transaction = !in_transaction?
|
|
89
95
|
|
|
90
96
|
ops =
|
|
91
97
|
if new_transaction
|
|
92
|
-
Thread.current[:edge_transaction] = Flock::ExecuteOperations.new(@service, priority)
|
|
98
|
+
Thread.current[:edge_transaction] = Flock::ExecuteOperations.new(@service, priority, execute_at)
|
|
93
99
|
else
|
|
94
100
|
current_transaction
|
|
95
101
|
end
|
|
@@ -238,12 +238,11 @@ require 'flockdb_types'
|
|
|
238
238
|
# HELPER FUNCTIONS AND STRUCTURES
|
|
239
239
|
|
|
240
240
|
class Contains_args
|
|
241
|
-
include ::Thrift::Struct
|
|
241
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
|
242
242
|
SOURCE_ID = 1
|
|
243
243
|
GRAPH_ID = 2
|
|
244
244
|
DESTINATION_ID = 3
|
|
245
245
|
|
|
246
|
-
::Thrift::Struct.field_accessor self, :source_id, :graph_id, :destination_id
|
|
247
246
|
FIELDS = {
|
|
248
247
|
SOURCE_ID => {:type => ::Thrift::Types::I64, :name => 'source_id'},
|
|
249
248
|
GRAPH_ID => {:type => ::Thrift::Types::I32, :name => 'graph_id'},
|
|
@@ -255,14 +254,14 @@ require 'flockdb_types'
|
|
|
255
254
|
def validate
|
|
256
255
|
end
|
|
257
256
|
|
|
257
|
+
::Thrift::Struct.generate_accessors self
|
|
258
258
|
end
|
|
259
259
|
|
|
260
260
|
class Contains_result
|
|
261
|
-
include ::Thrift::Struct
|
|
261
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
|
262
262
|
SUCCESS = 0
|
|
263
263
|
EX = 1
|
|
264
264
|
|
|
265
|
-
::Thrift::Struct.field_accessor self, :success, :ex
|
|
266
265
|
FIELDS = {
|
|
267
266
|
SUCCESS => {:type => ::Thrift::Types::BOOL, :name => 'success'},
|
|
268
267
|
EX => {:type => ::Thrift::Types::STRUCT, :name => 'ex', :class => Flock::Edges::FlockException}
|
|
@@ -273,15 +272,15 @@ require 'flockdb_types'
|
|
|
273
272
|
def validate
|
|
274
273
|
end
|
|
275
274
|
|
|
275
|
+
::Thrift::Struct.generate_accessors self
|
|
276
276
|
end
|
|
277
277
|
|
|
278
278
|
class Get_args
|
|
279
|
-
include ::Thrift::Struct
|
|
279
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
|
280
280
|
SOURCE_ID = 1
|
|
281
281
|
GRAPH_ID = 2
|
|
282
282
|
DESTINATION_ID = 3
|
|
283
283
|
|
|
284
|
-
::Thrift::Struct.field_accessor self, :source_id, :graph_id, :destination_id
|
|
285
284
|
FIELDS = {
|
|
286
285
|
SOURCE_ID => {:type => ::Thrift::Types::I64, :name => 'source_id'},
|
|
287
286
|
GRAPH_ID => {:type => ::Thrift::Types::I32, :name => 'graph_id'},
|
|
@@ -293,14 +292,14 @@ require 'flockdb_types'
|
|
|
293
292
|
def validate
|
|
294
293
|
end
|
|
295
294
|
|
|
295
|
+
::Thrift::Struct.generate_accessors self
|
|
296
296
|
end
|
|
297
297
|
|
|
298
298
|
class Get_result
|
|
299
|
-
include ::Thrift::Struct
|
|
299
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
|
300
300
|
SUCCESS = 0
|
|
301
301
|
EX = 1
|
|
302
302
|
|
|
303
|
-
::Thrift::Struct.field_accessor self, :success, :ex
|
|
304
303
|
FIELDS = {
|
|
305
304
|
SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Flock::Edges::Edge},
|
|
306
305
|
EX => {:type => ::Thrift::Types::STRUCT, :name => 'ex', :class => Flock::Edges::FlockException}
|
|
@@ -311,13 +310,13 @@ require 'flockdb_types'
|
|
|
311
310
|
def validate
|
|
312
311
|
end
|
|
313
312
|
|
|
313
|
+
::Thrift::Struct.generate_accessors self
|
|
314
314
|
end
|
|
315
315
|
|
|
316
316
|
class Select2_args
|
|
317
|
-
include ::Thrift::Struct
|
|
317
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
|
318
318
|
QUERIES = 1
|
|
319
319
|
|
|
320
|
-
::Thrift::Struct.field_accessor self, :queries
|
|
321
320
|
FIELDS = {
|
|
322
321
|
QUERIES => {:type => ::Thrift::Types::LIST, :name => 'queries', :element => {:type => ::Thrift::Types::STRUCT, :class => Flock::Edges::SelectQuery}}
|
|
323
322
|
}
|
|
@@ -327,14 +326,14 @@ require 'flockdb_types'
|
|
|
327
326
|
def validate
|
|
328
327
|
end
|
|
329
328
|
|
|
329
|
+
::Thrift::Struct.generate_accessors self
|
|
330
330
|
end
|
|
331
331
|
|
|
332
332
|
class Select2_result
|
|
333
|
-
include ::Thrift::Struct
|
|
333
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
|
334
334
|
SUCCESS = 0
|
|
335
335
|
EX = 1
|
|
336
336
|
|
|
337
|
-
::Thrift::Struct.field_accessor self, :success, :ex
|
|
338
337
|
FIELDS = {
|
|
339
338
|
SUCCESS => {:type => ::Thrift::Types::LIST, :name => 'success', :element => {:type => ::Thrift::Types::STRUCT, :class => Flock::Edges::Results}},
|
|
340
339
|
EX => {:type => ::Thrift::Types::STRUCT, :name => 'ex', :class => Flock::Edges::FlockException}
|
|
@@ -345,13 +344,13 @@ require 'flockdb_types'
|
|
|
345
344
|
def validate
|
|
346
345
|
end
|
|
347
346
|
|
|
347
|
+
::Thrift::Struct.generate_accessors self
|
|
348
348
|
end
|
|
349
349
|
|
|
350
350
|
class Count2_args
|
|
351
|
-
include ::Thrift::Struct
|
|
351
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
|
352
352
|
QUERIES = 1
|
|
353
353
|
|
|
354
|
-
::Thrift::Struct.field_accessor self, :queries
|
|
355
354
|
FIELDS = {
|
|
356
355
|
QUERIES => {:type => ::Thrift::Types::LIST, :name => 'queries', :element => {:type => ::Thrift::Types::LIST, :element => {:type => ::Thrift::Types::STRUCT, :class => Flock::Edges::SelectOperation}}}
|
|
357
356
|
}
|
|
@@ -361,16 +360,16 @@ require 'flockdb_types'
|
|
|
361
360
|
def validate
|
|
362
361
|
end
|
|
363
362
|
|
|
363
|
+
::Thrift::Struct.generate_accessors self
|
|
364
364
|
end
|
|
365
365
|
|
|
366
366
|
class Count2_result
|
|
367
|
-
include ::Thrift::Struct
|
|
367
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
|
368
368
|
SUCCESS = 0
|
|
369
369
|
EX = 1
|
|
370
370
|
|
|
371
|
-
::Thrift::Struct.field_accessor self, :success, :ex
|
|
372
371
|
FIELDS = {
|
|
373
|
-
SUCCESS => {:type => ::Thrift::Types::STRING, :name => 'success'},
|
|
372
|
+
SUCCESS => {:type => ::Thrift::Types::STRING, :name => 'success', :binary => true},
|
|
374
373
|
EX => {:type => ::Thrift::Types::STRUCT, :name => 'ex', :class => Flock::Edges::FlockException}
|
|
375
374
|
}
|
|
376
375
|
|
|
@@ -379,13 +378,13 @@ require 'flockdb_types'
|
|
|
379
378
|
def validate
|
|
380
379
|
end
|
|
381
380
|
|
|
381
|
+
::Thrift::Struct.generate_accessors self
|
|
382
382
|
end
|
|
383
383
|
|
|
384
384
|
class Select_edges_args
|
|
385
|
-
include ::Thrift::Struct
|
|
385
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
|
386
386
|
QUERIES = 1
|
|
387
387
|
|
|
388
|
-
::Thrift::Struct.field_accessor self, :queries
|
|
389
388
|
FIELDS = {
|
|
390
389
|
QUERIES => {:type => ::Thrift::Types::LIST, :name => 'queries', :element => {:type => ::Thrift::Types::STRUCT, :class => Flock::Edges::EdgeQuery}}
|
|
391
390
|
}
|
|
@@ -395,14 +394,14 @@ require 'flockdb_types'
|
|
|
395
394
|
def validate
|
|
396
395
|
end
|
|
397
396
|
|
|
397
|
+
::Thrift::Struct.generate_accessors self
|
|
398
398
|
end
|
|
399
399
|
|
|
400
400
|
class Select_edges_result
|
|
401
|
-
include ::Thrift::Struct
|
|
401
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
|
402
402
|
SUCCESS = 0
|
|
403
403
|
EX = 1
|
|
404
404
|
|
|
405
|
-
::Thrift::Struct.field_accessor self, :success, :ex
|
|
406
405
|
FIELDS = {
|
|
407
406
|
SUCCESS => {:type => ::Thrift::Types::LIST, :name => 'success', :element => {:type => ::Thrift::Types::STRUCT, :class => Flock::Edges::EdgeResults}},
|
|
408
407
|
EX => {:type => ::Thrift::Types::STRUCT, :name => 'ex', :class => Flock::Edges::FlockException}
|
|
@@ -413,13 +412,13 @@ require 'flockdb_types'
|
|
|
413
412
|
def validate
|
|
414
413
|
end
|
|
415
414
|
|
|
415
|
+
::Thrift::Struct.generate_accessors self
|
|
416
416
|
end
|
|
417
417
|
|
|
418
418
|
class Execute_args
|
|
419
|
-
include ::Thrift::Struct
|
|
419
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
|
420
420
|
OPERATIONS = 1
|
|
421
421
|
|
|
422
|
-
::Thrift::Struct.field_accessor self, :operations
|
|
423
422
|
FIELDS = {
|
|
424
423
|
OPERATIONS => {:type => ::Thrift::Types::STRUCT, :name => 'operations', :class => Flock::Edges::ExecuteOperations}
|
|
425
424
|
}
|
|
@@ -429,13 +428,13 @@ require 'flockdb_types'
|
|
|
429
428
|
def validate
|
|
430
429
|
end
|
|
431
430
|
|
|
431
|
+
::Thrift::Struct.generate_accessors self
|
|
432
432
|
end
|
|
433
433
|
|
|
434
434
|
class Execute_result
|
|
435
|
-
include ::Thrift::Struct
|
|
435
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
|
436
436
|
EX = 1
|
|
437
437
|
|
|
438
|
-
::Thrift::Struct.field_accessor self, :ex
|
|
439
438
|
FIELDS = {
|
|
440
439
|
EX => {:type => ::Thrift::Types::STRUCT, :name => 'ex', :class => Flock::Edges::FlockException}
|
|
441
440
|
}
|
|
@@ -445,13 +444,13 @@ require 'flockdb_types'
|
|
|
445
444
|
def validate
|
|
446
445
|
end
|
|
447
446
|
|
|
447
|
+
::Thrift::Struct.generate_accessors self
|
|
448
448
|
end
|
|
449
449
|
|
|
450
450
|
class Count_args
|
|
451
|
-
include ::Thrift::Struct
|
|
451
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
|
452
452
|
OPERATIONS = 1
|
|
453
453
|
|
|
454
|
-
::Thrift::Struct.field_accessor self, :operations
|
|
455
454
|
FIELDS = {
|
|
456
455
|
OPERATIONS => {:type => ::Thrift::Types::LIST, :name => 'operations', :element => {:type => ::Thrift::Types::STRUCT, :class => Flock::Edges::SelectOperation}}
|
|
457
456
|
}
|
|
@@ -461,14 +460,14 @@ require 'flockdb_types'
|
|
|
461
460
|
def validate
|
|
462
461
|
end
|
|
463
462
|
|
|
463
|
+
::Thrift::Struct.generate_accessors self
|
|
464
464
|
end
|
|
465
465
|
|
|
466
466
|
class Count_result
|
|
467
|
-
include ::Thrift::Struct
|
|
467
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
|
468
468
|
SUCCESS = 0
|
|
469
469
|
EX = 1
|
|
470
470
|
|
|
471
|
-
::Thrift::Struct.field_accessor self, :success, :ex
|
|
472
471
|
FIELDS = {
|
|
473
472
|
SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'},
|
|
474
473
|
EX => {:type => ::Thrift::Types::STRUCT, :name => 'ex', :class => Flock::Edges::FlockException}
|
|
@@ -479,14 +478,14 @@ require 'flockdb_types'
|
|
|
479
478
|
def validate
|
|
480
479
|
end
|
|
481
480
|
|
|
481
|
+
::Thrift::Struct.generate_accessors self
|
|
482
482
|
end
|
|
483
483
|
|
|
484
484
|
class Select_args
|
|
485
|
-
include ::Thrift::Struct
|
|
485
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
|
486
486
|
OPERATIONS = 1
|
|
487
487
|
PAGE = 2
|
|
488
488
|
|
|
489
|
-
::Thrift::Struct.field_accessor self, :operations, :page
|
|
490
489
|
FIELDS = {
|
|
491
490
|
OPERATIONS => {:type => ::Thrift::Types::LIST, :name => 'operations', :element => {:type => ::Thrift::Types::STRUCT, :class => Flock::Edges::SelectOperation}},
|
|
492
491
|
PAGE => {:type => ::Thrift::Types::STRUCT, :name => 'page', :class => Flock::Edges::Page}
|
|
@@ -497,14 +496,14 @@ require 'flockdb_types'
|
|
|
497
496
|
def validate
|
|
498
497
|
end
|
|
499
498
|
|
|
499
|
+
::Thrift::Struct.generate_accessors self
|
|
500
500
|
end
|
|
501
501
|
|
|
502
502
|
class Select_result
|
|
503
|
-
include ::Thrift::Struct
|
|
503
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
|
504
504
|
SUCCESS = 0
|
|
505
505
|
EX = 1
|
|
506
506
|
|
|
507
|
-
::Thrift::Struct.field_accessor self, :success, :ex
|
|
508
507
|
FIELDS = {
|
|
509
508
|
SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Flock::Edges::Results},
|
|
510
509
|
EX => {:type => ::Thrift::Types::STRUCT, :name => 'ex', :class => Flock::Edges::FlockException}
|
|
@@ -515,6 +514,7 @@ require 'flockdb_types'
|
|
|
515
514
|
def validate
|
|
516
515
|
end
|
|
517
516
|
|
|
517
|
+
::Thrift::Struct.generate_accessors self
|
|
518
518
|
end
|
|
519
519
|
|
|
520
520
|
end
|
|
@@ -43,7 +43,7 @@ module Flock
|
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
class FlockException < ::Thrift::Exception
|
|
46
|
-
include ::Thrift::Struct
|
|
46
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
|
47
47
|
def initialize(message=nil)
|
|
48
48
|
super()
|
|
49
49
|
self.description = message
|
|
@@ -53,7 +53,6 @@ module Flock
|
|
|
53
53
|
|
|
54
54
|
DESCRIPTION = 1
|
|
55
55
|
|
|
56
|
-
::Thrift::Struct.field_accessor self, :description
|
|
57
56
|
FIELDS = {
|
|
58
57
|
DESCRIPTION => {:type => ::Thrift::Types::STRING, :name => 'description'}
|
|
59
58
|
}
|
|
@@ -63,17 +62,17 @@ module Flock
|
|
|
63
62
|
def validate
|
|
64
63
|
end
|
|
65
64
|
|
|
65
|
+
::Thrift::Struct.generate_accessors self
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
class Results
|
|
69
|
-
include ::Thrift::Struct
|
|
69
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
|
70
70
|
IDS = 1
|
|
71
71
|
NEXT_CURSOR = 2
|
|
72
72
|
PREV_CURSOR = 3
|
|
73
73
|
|
|
74
|
-
::Thrift::Struct.field_accessor self, :ids, :next_cursor, :prev_cursor
|
|
75
74
|
FIELDS = {
|
|
76
|
-
IDS => {:type => ::Thrift::Types::STRING, :name => 'ids'},
|
|
75
|
+
IDS => {:type => ::Thrift::Types::STRING, :name => 'ids', :binary => true},
|
|
77
76
|
NEXT_CURSOR => {:type => ::Thrift::Types::I64, :name => 'next_cursor'},
|
|
78
77
|
PREV_CURSOR => {:type => ::Thrift::Types::I64, :name => 'prev_cursor'}
|
|
79
78
|
}
|
|
@@ -83,14 +82,14 @@ module Flock
|
|
|
83
82
|
def validate
|
|
84
83
|
end
|
|
85
84
|
|
|
85
|
+
::Thrift::Struct.generate_accessors self
|
|
86
86
|
end
|
|
87
87
|
|
|
88
88
|
class Page
|
|
89
|
-
include ::Thrift::Struct
|
|
89
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
|
90
90
|
COUNT = 1
|
|
91
91
|
CURSOR = 2
|
|
92
92
|
|
|
93
|
-
::Thrift::Struct.field_accessor self, :count, :cursor
|
|
94
93
|
FIELDS = {
|
|
95
94
|
COUNT => {:type => ::Thrift::Types::I32, :name => 'count'},
|
|
96
95
|
CURSOR => {:type => ::Thrift::Types::I64, :name => 'cursor'}
|
|
@@ -101,10 +100,11 @@ module Flock
|
|
|
101
100
|
def validate
|
|
102
101
|
end
|
|
103
102
|
|
|
103
|
+
::Thrift::Struct.generate_accessors self
|
|
104
104
|
end
|
|
105
105
|
|
|
106
106
|
class Edge
|
|
107
|
-
include ::Thrift::Struct
|
|
107
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
|
108
108
|
SOURCE_ID = 1
|
|
109
109
|
DESTINATION_ID = 2
|
|
110
110
|
POSITION = 3
|
|
@@ -112,7 +112,6 @@ module Flock
|
|
|
112
112
|
COUNT = 5
|
|
113
113
|
STATE_ID = 6
|
|
114
114
|
|
|
115
|
-
::Thrift::Struct.field_accessor self, :source_id, :destination_id, :position, :updated_at, :count, :state_id
|
|
116
115
|
FIELDS = {
|
|
117
116
|
SOURCE_ID => {:type => ::Thrift::Types::I64, :name => 'source_id'},
|
|
118
117
|
DESTINATION_ID => {:type => ::Thrift::Types::I64, :name => 'destination_id'},
|
|
@@ -127,22 +126,22 @@ module Flock
|
|
|
127
126
|
def validate
|
|
128
127
|
end
|
|
129
128
|
|
|
129
|
+
::Thrift::Struct.generate_accessors self
|
|
130
130
|
end
|
|
131
131
|
|
|
132
132
|
class QueryTerm
|
|
133
|
-
include ::Thrift::Struct
|
|
133
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
|
134
134
|
SOURCE_ID = 1
|
|
135
135
|
GRAPH_ID = 2
|
|
136
136
|
IS_FORWARD = 3
|
|
137
137
|
DESTINATION_IDS = 4
|
|
138
138
|
STATE_IDS = 5
|
|
139
139
|
|
|
140
|
-
::Thrift::Struct.field_accessor self, :source_id, :graph_id, :is_forward, :destination_ids, :state_ids
|
|
141
140
|
FIELDS = {
|
|
142
141
|
SOURCE_ID => {:type => ::Thrift::Types::I64, :name => 'source_id'},
|
|
143
142
|
GRAPH_ID => {:type => ::Thrift::Types::I32, :name => 'graph_id'},
|
|
144
143
|
IS_FORWARD => {:type => ::Thrift::Types::BOOL, :name => 'is_forward'},
|
|
145
|
-
DESTINATION_IDS => {:type => ::Thrift::Types::STRING, :name => 'destination_ids', :optional => true},
|
|
144
|
+
DESTINATION_IDS => {:type => ::Thrift::Types::STRING, :name => 'destination_ids', :binary => true, :optional => true},
|
|
146
145
|
STATE_IDS => {:type => ::Thrift::Types::LIST, :name => 'state_ids', :element => {:type => ::Thrift::Types::I32}, :optional => true}
|
|
147
146
|
}
|
|
148
147
|
|
|
@@ -151,14 +150,14 @@ module Flock
|
|
|
151
150
|
def validate
|
|
152
151
|
end
|
|
153
152
|
|
|
153
|
+
::Thrift::Struct.generate_accessors self
|
|
154
154
|
end
|
|
155
155
|
|
|
156
156
|
class SelectOperation
|
|
157
|
-
include ::Thrift::Struct
|
|
157
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
|
158
158
|
OPERATION_TYPE = 1
|
|
159
159
|
TERM = 2
|
|
160
160
|
|
|
161
|
-
::Thrift::Struct.field_accessor self, :operation_type, :term
|
|
162
161
|
FIELDS = {
|
|
163
162
|
OPERATION_TYPE => {:type => ::Thrift::Types::I32, :name => 'operation_type', :enum_class => Flock::Edges::SelectOperationType},
|
|
164
163
|
TERM => {:type => ::Thrift::Types::STRUCT, :name => 'term', :class => Flock::Edges::QueryTerm, :optional => true}
|
|
@@ -172,15 +171,15 @@ module Flock
|
|
|
172
171
|
end
|
|
173
172
|
end
|
|
174
173
|
|
|
174
|
+
::Thrift::Struct.generate_accessors self
|
|
175
175
|
end
|
|
176
176
|
|
|
177
177
|
class ExecuteOperation
|
|
178
|
-
include ::Thrift::Struct
|
|
178
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
|
179
179
|
OPERATION_TYPE = 1
|
|
180
180
|
TERM = 2
|
|
181
181
|
POSITION = 3
|
|
182
182
|
|
|
183
|
-
::Thrift::Struct.field_accessor self, :operation_type, :term, :position
|
|
184
183
|
FIELDS = {
|
|
185
184
|
OPERATION_TYPE => {:type => ::Thrift::Types::I32, :name => 'operation_type', :enum_class => Flock::Edges::ExecuteOperationType},
|
|
186
185
|
TERM => {:type => ::Thrift::Types::STRUCT, :name => 'term', :class => Flock::Edges::QueryTerm},
|
|
@@ -195,15 +194,15 @@ module Flock
|
|
|
195
194
|
end
|
|
196
195
|
end
|
|
197
196
|
|
|
197
|
+
::Thrift::Struct.generate_accessors self
|
|
198
198
|
end
|
|
199
199
|
|
|
200
200
|
class ExecuteOperations
|
|
201
|
-
include ::Thrift::Struct
|
|
201
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
|
202
202
|
OPERATIONS = 1
|
|
203
203
|
EXECUTE_AT = 2
|
|
204
204
|
PRIORITY = 3
|
|
205
205
|
|
|
206
|
-
::Thrift::Struct.field_accessor self, :operations, :execute_at, :priority
|
|
207
206
|
FIELDS = {
|
|
208
207
|
OPERATIONS => {:type => ::Thrift::Types::LIST, :name => 'operations', :element => {:type => ::Thrift::Types::STRUCT, :class => Flock::Edges::ExecuteOperation}},
|
|
209
208
|
EXECUTE_AT => {:type => ::Thrift::Types::I32, :name => 'execute_at', :optional => true},
|
|
@@ -218,14 +217,14 @@ module Flock
|
|
|
218
217
|
end
|
|
219
218
|
end
|
|
220
219
|
|
|
220
|
+
::Thrift::Struct.generate_accessors self
|
|
221
221
|
end
|
|
222
222
|
|
|
223
223
|
class SelectQuery
|
|
224
|
-
include ::Thrift::Struct
|
|
224
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
|
225
225
|
OPERATIONS = 1
|
|
226
226
|
PAGE = 2
|
|
227
227
|
|
|
228
|
-
::Thrift::Struct.field_accessor self, :operations, :page
|
|
229
228
|
FIELDS = {
|
|
230
229
|
OPERATIONS => {:type => ::Thrift::Types::LIST, :name => 'operations', :element => {:type => ::Thrift::Types::STRUCT, :class => Flock::Edges::SelectOperation}},
|
|
231
230
|
PAGE => {:type => ::Thrift::Types::STRUCT, :name => 'page', :class => Flock::Edges::Page}
|
|
@@ -236,14 +235,14 @@ module Flock
|
|
|
236
235
|
def validate
|
|
237
236
|
end
|
|
238
237
|
|
|
238
|
+
::Thrift::Struct.generate_accessors self
|
|
239
239
|
end
|
|
240
240
|
|
|
241
241
|
class EdgeQuery
|
|
242
|
-
include ::Thrift::Struct
|
|
242
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
|
243
243
|
TERM = 1
|
|
244
244
|
PAGE = 2
|
|
245
245
|
|
|
246
|
-
::Thrift::Struct.field_accessor self, :term, :page
|
|
247
246
|
FIELDS = {
|
|
248
247
|
TERM => {:type => ::Thrift::Types::STRUCT, :name => 'term', :class => Flock::Edges::QueryTerm},
|
|
249
248
|
PAGE => {:type => ::Thrift::Types::STRUCT, :name => 'page', :class => Flock::Edges::Page}
|
|
@@ -254,15 +253,15 @@ module Flock
|
|
|
254
253
|
def validate
|
|
255
254
|
end
|
|
256
255
|
|
|
256
|
+
::Thrift::Struct.generate_accessors self
|
|
257
257
|
end
|
|
258
258
|
|
|
259
259
|
class EdgeResults
|
|
260
|
-
include ::Thrift::Struct
|
|
260
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
|
261
261
|
EDGES = 1
|
|
262
262
|
NEXT_CURSOR = 2
|
|
263
263
|
PREV_CURSOR = 3
|
|
264
264
|
|
|
265
|
-
::Thrift::Struct.field_accessor self, :edges, :next_cursor, :prev_cursor
|
|
266
265
|
FIELDS = {
|
|
267
266
|
EDGES => {:type => ::Thrift::Types::LIST, :name => 'edges', :element => {:type => ::Thrift::Types::STRUCT, :class => Flock::Edges::Edge}},
|
|
268
267
|
NEXT_CURSOR => {:type => ::Thrift::Types::I64, :name => 'next_cursor'},
|
|
@@ -274,6 +273,7 @@ module Flock
|
|
|
274
273
|
def validate
|
|
275
274
|
end
|
|
276
275
|
|
|
276
|
+
::Thrift::Struct.generate_accessors self
|
|
277
277
|
end
|
|
278
278
|
|
|
279
279
|
end
|
data/lib/flock/mock_service.rb
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
module Flock
|
|
2
2
|
class ExecuteOperation
|
|
3
|
-
def initialize(operation_type, query)
|
|
4
|
-
@operation_type, @query = operation_type, query
|
|
3
|
+
def initialize(operation_type, query, position = nil)
|
|
4
|
+
@operation_type, @query, @position = operation_type, query, position
|
|
5
5
|
end
|
|
6
6
|
|
|
7
7
|
def to_thrift
|
|
8
8
|
op = Edges::ExecuteOperation.new
|
|
9
9
|
op.operation_type = @operation_type
|
|
10
|
+
op.position = @position if @position
|
|
10
11
|
op.term = QueryTerm.new(@query).to_thrift
|
|
11
12
|
op
|
|
12
13
|
end
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
module Flock
|
|
2
2
|
class ExecuteOperations
|
|
3
|
-
def initialize(service, priority)
|
|
4
|
-
@service, @operations, @priority = service, [], priority
|
|
3
|
+
def initialize(service, priority, execute_at = nil)
|
|
4
|
+
@service, @operations, @priority, @execute_at = service, [], priority, execute_at
|
|
5
5
|
end
|
|
6
6
|
|
|
7
7
|
Flock::Edges::ExecuteOperationType::VALUE_MAP.each do |op_id, op|
|
|
8
8
|
op = op.downcase
|
|
9
|
-
class_eval "def #{op}(s, g, d); @operations << ExecuteOperation.new(#{op_id}, [s, g, d]); self end", __FILE__, __LINE__
|
|
9
|
+
class_eval "def #{op}(s, g, d, p = nil); @operations << ExecuteOperation.new(#{op_id}, [s, g, d], p); self end", __FILE__, __LINE__
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def apply
|
|
@@ -17,6 +17,7 @@ module Flock
|
|
|
17
17
|
operations = Edges::ExecuteOperations.new
|
|
18
18
|
operations.operations = @operations.map(&:to_thrift)
|
|
19
19
|
operations.priority = @priority
|
|
20
|
+
operations.execute_at = @execute_at.to_i if @execute_at
|
|
20
21
|
operations
|
|
21
22
|
end
|
|
22
23
|
end
|
|
@@ -3,9 +3,33 @@ require 'spec_helper'
|
|
|
3
3
|
describe Flock::ExecuteOperations do
|
|
4
4
|
describe "#negate" do
|
|
5
5
|
it "should create a negate opperation" do
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
service = Flock::MockService.new
|
|
7
|
+
mock(Flock::ExecuteOperation).new(Flock::Edges::ExecuteOperationType::Negate, [1,1,3], nil)
|
|
8
|
+
operation = Flock::ExecuteOperations.new(service, nil)
|
|
8
9
|
operation.negate(1,1,3)
|
|
9
10
|
end
|
|
10
11
|
end
|
|
12
|
+
|
|
13
|
+
describe "adding with timestamp" do
|
|
14
|
+
it "should pass through" do
|
|
15
|
+
service = Flock::MockService.new
|
|
16
|
+
client = Flock::Client.new(service)
|
|
17
|
+
now = Time.now.to_i
|
|
18
|
+
thing = Flock::ExecuteOperations.new(service, Flock::Priority::High, now)
|
|
19
|
+
mock(Flock::ExecuteOperations).new(service, Flock::Priority::High, now) { thing }
|
|
20
|
+
client.add(1, 1, 3, Flock::Priority::High, :execute_at => now)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
describe "adding with position" do
|
|
25
|
+
it "should pass through" do
|
|
26
|
+
service = Flock::MockService.new
|
|
27
|
+
client = Flock::Client.new(service)
|
|
28
|
+
now = Time.now.to_i
|
|
29
|
+
thing = Flock::ExecuteOperation.new(1, [1, 1, 3], 12345)
|
|
30
|
+
mock(Flock::ExecuteOperation).new(1, [1, 1, 3], 12345) { thing}
|
|
31
|
+
client.add(1, 1, 3, Flock::Priority::High, :position => 12345)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
11
35
|
end
|
data/spec/flock_spec.rb
CHANGED
|
@@ -16,6 +16,15 @@ describe Flock do
|
|
|
16
16
|
it 'works' do
|
|
17
17
|
flock.contains(1,1,2).should == true
|
|
18
18
|
end
|
|
19
|
+
|
|
20
|
+
it 'works within nested transactions' do
|
|
21
|
+
flock.transaction do
|
|
22
|
+
flock.transaction do |f|
|
|
23
|
+
f.add(1,1,5)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
flock.contains(1,1,5).should == true
|
|
27
|
+
end
|
|
19
28
|
end
|
|
20
29
|
|
|
21
30
|
describe 'remove' do
|
|
@@ -3,8 +3,9 @@ require 'spec_helper'
|
|
|
3
3
|
describe Flock::ExecuteOperations do
|
|
4
4
|
describe "#negate" do
|
|
5
5
|
it "should create a negate operation" do
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
service = Flock::MockService.new
|
|
7
|
+
mock(Flock::ExecuteOperation).new(Flock::Edges::ExecuteOperationType::Negate, [1,1,3], nil)
|
|
8
|
+
operation = Flock::ExecuteOperations.new(Flock::Client.new(service), nil)
|
|
8
9
|
operation.negate(1,1,3)
|
|
9
10
|
end
|
|
10
11
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -7,13 +7,15 @@ $: << File.expand_path("#{spec_dir}/../lib")
|
|
|
7
7
|
require 'flock'
|
|
8
8
|
require 'flock/mock_service'
|
|
9
9
|
|
|
10
|
+
$mock_service = Flock::MockService.new
|
|
11
|
+
|
|
10
12
|
Spec::Runner.configure do |config|
|
|
11
13
|
config.mock_with :rr
|
|
12
14
|
config.before do
|
|
13
|
-
|
|
15
|
+
$mock_service.clear
|
|
14
16
|
end
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
def new_flock_client
|
|
18
|
-
Flock.new(
|
|
20
|
+
Flock.new($mock_service)
|
|
19
21
|
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: flockdb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 5
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
|
-
-
|
|
8
|
+
- 6
|
|
9
9
|
- 1
|
|
10
|
-
version: 0.
|
|
10
|
+
version: 0.6.1
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Matt Freels
|
|
@@ -17,7 +17,7 @@ autorequire:
|
|
|
17
17
|
bindir: bin
|
|
18
18
|
cert_chain: []
|
|
19
19
|
|
|
20
|
-
date:
|
|
20
|
+
date: 2011-02-28 00:00:00 -08:00
|
|
21
21
|
default_executable:
|
|
22
22
|
dependencies:
|
|
23
23
|
- !ruby/object:Gem::Dependency
|
|
@@ -28,12 +28,12 @@ dependencies:
|
|
|
28
28
|
requirements:
|
|
29
29
|
- - ">="
|
|
30
30
|
- !ruby/object:Gem::Version
|
|
31
|
-
hash:
|
|
31
|
+
hash: 11
|
|
32
32
|
segments:
|
|
33
33
|
- 0
|
|
34
|
-
-
|
|
34
|
+
- 5
|
|
35
35
|
- 0
|
|
36
|
-
version: 0.
|
|
36
|
+
version: 0.5.0
|
|
37
37
|
type: :runtime
|
|
38
38
|
version_requirements: *id001
|
|
39
39
|
- !ruby/object:Gem::Dependency
|
|
@@ -44,12 +44,12 @@ dependencies:
|
|
|
44
44
|
requirements:
|
|
45
45
|
- - ">="
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
hash:
|
|
47
|
+
hash: 7
|
|
48
48
|
segments:
|
|
49
49
|
- 0
|
|
50
|
-
-
|
|
51
|
-
-
|
|
52
|
-
version: 0.
|
|
50
|
+
- 6
|
|
51
|
+
- 0
|
|
52
|
+
version: 0.6.0
|
|
53
53
|
type: :runtime
|
|
54
54
|
version_requirements: *id002
|
|
55
55
|
- !ruby/object:Gem::Dependency
|