thrift_client 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/lib/thrift_client.rb +20 -13
- data/thrift_client.gemspec +1 -1
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +1 -3
data/CHANGELOG
CHANGED
data/lib/thrift_client.rb
CHANGED
@@ -52,7 +52,24 @@ Valid optional parameters are:
|
|
52
52
|
|
53
53
|
@set_timeout = @options[:transport].instance_methods.include?("timeout=")
|
54
54
|
@live_server_list = @server_list.dup
|
55
|
-
@last_retry = Time.now
|
55
|
+
@last_retry = Time.now
|
56
|
+
|
57
|
+
@client_class.instance_methods.each do |method_name|
|
58
|
+
if method_name =~ /^recv_(.*)$/
|
59
|
+
instance_eval("def #{$1}(*args); proxy(:'#{$1}', *args); end")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# Force the client to connect to the server.
|
65
|
+
def connect!
|
66
|
+
server = next_server.to_s.split(":")
|
67
|
+
raise ArgumentError, 'Servers must be in the form "host:port"' if server.size != 2
|
68
|
+
|
69
|
+
@transport = @options[:transport].new(
|
70
|
+
Thrift::Socket.new(server.first, server.last.to_i, @options[:timeouts].default))
|
71
|
+
@transport.open
|
72
|
+
@client = @client_class.new(@options[:protocol].new(@transport, false))
|
56
73
|
end
|
57
74
|
|
58
75
|
# Force the client to disconnect from the server.
|
@@ -63,7 +80,7 @@ Valid optional parameters are:
|
|
63
80
|
|
64
81
|
private
|
65
82
|
|
66
|
-
def
|
83
|
+
def proxy(method_name, *args)
|
67
84
|
connect! unless @client
|
68
85
|
set_timeout!(method_name) if @set_timeout
|
69
86
|
@client.send(method_name, *args)
|
@@ -87,16 +104,6 @@ Valid optional parameters are:
|
|
87
104
|
@options[:defaults][method_name.to_sym]
|
88
105
|
end
|
89
106
|
|
90
|
-
def connect!
|
91
|
-
server = next_server.to_s.split(":")
|
92
|
-
raise ArgumentError, 'Servers must be in the form "host:port"' if server.size != 2
|
93
|
-
|
94
|
-
@transport = @options[:transport].new(
|
95
|
-
Thrift::Socket.new(server.first, server.last.to_i, @options[:timeouts].default))
|
96
|
-
@transport.open
|
97
|
-
@client = @client_class.new(@options[:protocol].new(@transport, false))
|
98
|
-
end
|
99
|
-
|
100
107
|
def next_server
|
101
108
|
if @live_server_list.empty?
|
102
109
|
if @options[:server_retry_period] and Time.now < @last_retry + @options[:server_retry_period]
|
@@ -106,5 +113,5 @@ Valid optional parameters are:
|
|
106
113
|
@live_server_list = @server_list.dup
|
107
114
|
end
|
108
115
|
@live_server_list.pop
|
109
|
-
end
|
116
|
+
end
|
110
117
|
end
|
data/thrift_client.gemspec
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
@@ -1,3 +1 @@
|
|
1
|
-
|
2
|
-
�*h4�3N��[s6���0�P1���P~R?���vf�h�����O.n�)��<Q}}Jċ���%��b�~��i�V+ȝ��@����=B0�f]�JU��8H����/&��'�yA�L��唄�(�Z*�f��;�gnk�B,=��� ���
|
3
|
-
nL��,��O5�6:�#�ި
|
1
|
+
z���]�H7���=_�i~���Pl:Em�P:�ގ���?�2U�ix���a�qyY����\B���S�R#e0�a��h0{"��Q��t��JJ�,��^��*+yI}�2���������{<�9FV�MV��c&��-��|�w�Jk -�d���� ���$Ҿ�/�q�������η D�S2���.����x��<�.X�������l�Uн�����f�\"�=I�C������fgMW
|