thrifter 0.1.2 → 0.1.3
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.
- checksums.yaml +4 -4
- data/lib/thrifter/extensions/queueing.rb +22 -12
- data/lib/thrifter/extensions/retriable.rb +9 -11
- data/lib/thrifter/version.rb +1 -1
- data/test/extensions/queueing_test.rb +6 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f749536c8bf5a2560c17986f6ef8a38828aedc22
|
4
|
+
data.tar.gz: 3a1e08e6e213162ac77ceffb70c329bfa7ce0756
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6429f24abd079c31a99e0701dbe051d9f63716776175028a56c9a65526486fc606cdcc8e107ccffcad77ae9cc75c2c52c84dbe2f24fb611f77cd5cb105f48686
|
7
|
+
data.tar.gz: 4344478d6dc7553594d54b89f274ad4854e196e01c20d36fc219fbc356113068282fa6e113611ced192e6add67b693b85706f5535cfa82b70ddaf377e0193a21
|
@@ -12,27 +12,37 @@ module Thrifter
|
|
12
12
|
# other structure. This is why the method has so many arguments.
|
13
13
|
# Sidekik-thrift_arguments will correctly pick up any complex
|
14
14
|
# type in the splat and handle serialization/deserialization
|
15
|
-
def perform(klass,
|
15
|
+
def perform(klass, method_name, *args)
|
16
16
|
client = klass.constantize.new
|
17
|
-
client.send
|
17
|
+
client.send method_name, *args
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
class Proxy
|
22
|
-
def initialize(
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
21
|
+
class Proxy < BasicObject
|
22
|
+
def initialize(target)
|
23
|
+
@target = target
|
24
|
+
end
|
25
|
+
|
26
|
+
def method_missing(name, *args, &block)
|
27
|
+
if target.respond_to? name
|
28
|
+
job_args = [ target.class.to_s, name ].concat(args)
|
29
|
+
Job.perform_async(*job_args)
|
30
|
+
else
|
31
|
+
super
|
28
32
|
end
|
29
33
|
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def target
|
38
|
+
@target
|
39
|
+
end
|
30
40
|
end
|
31
41
|
|
32
42
|
def queued
|
33
|
-
Proxy.new
|
34
|
-
|
35
|
-
|
43
|
+
proxy = Proxy.new self
|
44
|
+
yield proxy if block_given?
|
45
|
+
proxy
|
36
46
|
end
|
37
47
|
end
|
38
48
|
end
|
@@ -16,21 +16,19 @@ module Thrifter
|
|
16
16
|
Errno::ETIMEDOUT
|
17
17
|
]
|
18
18
|
|
19
|
-
class Proxy
|
19
|
+
class Proxy < BasicObject
|
20
20
|
attr_reader :tries, :interval, :client
|
21
21
|
|
22
|
-
def initialize(client, tries, interval
|
22
|
+
def initialize(client, tries, interval)
|
23
23
|
@client, @tries, @interval = client, tries, interval
|
24
|
-
|
25
|
-
rpcs.each do |name|
|
26
|
-
define_singleton_method name do |*args|
|
27
|
-
invoke_with_retry(name, *args)
|
28
|
-
end
|
29
|
-
end
|
30
24
|
end
|
31
25
|
|
32
26
|
private
|
33
27
|
|
28
|
+
def method_missing(name, *args)
|
29
|
+
invoke_with_retry(name, *args)
|
30
|
+
end
|
31
|
+
|
34
32
|
def invoke_with_retry(name, *args)
|
35
33
|
counter = 0
|
36
34
|
|
@@ -49,9 +47,9 @@ module Thrifter
|
|
49
47
|
end
|
50
48
|
|
51
49
|
def with_retry(tries: 5, interval: 0.01)
|
52
|
-
Proxy.new
|
53
|
-
|
54
|
-
|
50
|
+
proxy = Proxy.new self, tries, interval
|
51
|
+
yield proxy if block_given?
|
52
|
+
proxy
|
55
53
|
end
|
56
54
|
end
|
57
55
|
end
|
data/lib/thrifter/version.rb
CHANGED
@@ -12,6 +12,10 @@ class QueuingTest < MiniTest::Unit::TestCase
|
|
12
12
|
include Thrifter::Queueing
|
13
13
|
|
14
14
|
self.config.uri = 'tcp://localhost:9090'
|
15
|
+
|
16
|
+
def custom_echo
|
17
|
+
echo TestMessage.new(message: 'custom')
|
18
|
+
end
|
15
19
|
end
|
16
20
|
|
17
21
|
def queue
|
@@ -26,7 +30,7 @@ class QueuingTest < MiniTest::Unit::TestCase
|
|
26
30
|
queue.clear
|
27
31
|
end
|
28
32
|
|
29
|
-
def
|
33
|
+
def test_queues_methods_with_sidekiq
|
30
34
|
client = QueuedClient.new
|
31
35
|
|
32
36
|
message = TestMessage.new message: 'echo'
|
@@ -62,7 +66,7 @@ class QueuingTest < MiniTest::Unit::TestCase
|
|
62
66
|
refute jobs.empty?, 'Nothing enqueued'
|
63
67
|
end
|
64
68
|
|
65
|
-
def
|
69
|
+
def test_fails_if_given_unknown_method
|
66
70
|
client = QueuedClient.new
|
67
71
|
message = TestMessage.new message: 'echo'
|
68
72
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thrifter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ahawkins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thrift
|