protobuf 3.0.0.rc1 → 3.0.0.rc2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f5adb66133630992323a9997d949111915d8829
4
- data.tar.gz: 7e38efbe7179f878ba6851d7b959e2c4e9227399
3
+ metadata.gz: c8eb56b50b5911d64b5634ac4c82dd27ba291c70
4
+ data.tar.gz: 0f1707982fc81dcca0638f51a7efc0a91b50c11b
5
5
  SHA512:
6
- metadata.gz: a5753795f4b427bad944603d34eacd68ba6f649104f841ffbd6f32ba09413206f0113087b588023ffaa5390ab96ddc4b669cb72a8dde924eb3b9818f9283ad79
7
- data.tar.gz: 9144fc91254485e6af4bb9d25db6b2401a50a63920d2749ef262069802a2d0787020a65f81ac098b0f16f0fa6ac4b1a28a231d3997c8c6b3d5a5727e0e82a563
6
+ metadata.gz: 140f2c71c05670f79fe461ec55307c42d2c32a839a07e568e627193dfbec4efd252d1bbd807050aa9cff2f52e196f225d531498bd5b95a6204ea54a0038e5399
7
+ data.tar.gz: 054234f0c8236ce49675694c9efc217d1c2c8a689472ef42b47523266ca18b9f4aa6b7b7519e1ea385213395e76571074b336b212604b61f88867af04a8668fa
@@ -1,8 +1,12 @@
1
1
  language: ruby
2
2
  rvm:
3
- - "1.9.2"
4
3
  - "1.9.3"
5
4
  - "2.0.0"
6
- script: NO_COMPILE_TEST_PROTOS=1 bundle exec rake spec
7
- before_install:
8
- - sudo apt-get install -qq libzmq3-dev
5
+ script: NO_COMPILE_TEST_PROTOS=1 bundle exec rake spec/lib
6
+ notifications:
7
+ webhooks:
8
+ urls:
9
+ - https://webhooks.gitter.im/e/51a956bcd2b1854d6756
10
+ on_success: change # options: [always|never|change] default: always
11
+ on_failure: always # options: [always|never|change] default: always
12
+ on_start: false # default: false
data/CHANGES.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Unstable
2
2
 
3
+ 3.0.0.rc2
4
+ ---------
5
+
6
+ Please read the [rc1 section below](#300rc1) for the greater changeset.
7
+
8
+ - Add support for assigning a symbol to a string or bytes field. [#181, @abrandoned]
9
+ - Add `first_alive_load_balance` option to rpc server. Pass `PB_FIRST_ALIVE_LOAD_BALANCE`
10
+ as an env variable to the client process to ensure the client asks the server
11
+ if it is alive (able to server requests to clients). [#183, @abrandoned]
12
+
13
+
3
14
  3.0.0.rc1
4
15
  ---------
5
16
 
@@ -48,6 +59,7 @@ __!! NOTE: These deprecated methods will be removed in v3.1. !!__
48
59
 
49
60
  #### Breaking Changes
50
61
 
62
+ - Require Active Support 3.2+. [#177]
51
63
  - All files/classes relating to the EventMachine client and server are gone. Use `PB_CLIENT_TYPE` and `PB_SERVER_TYPE` of `socket` instead. [#116]
52
64
  - Cleaned up the `Enum` class, deprecating/renaming most methods. tl;dr, just use `MyEnum.fetch`.
53
65
  See #134 for more comprehensive documentation about which methods are going and away and which are being renamed. [#134]
@@ -115,6 +115,11 @@ module Protobuf
115
115
  !! repeated
116
116
  end
117
117
 
118
+ # Is this a repeated message field?
119
+ def repeated_message?
120
+ repeated? && message?
121
+ end
122
+
118
123
  # Is this a required field?
119
124
  def required?
120
125
  !! required
@@ -23,11 +23,7 @@ module Protobuf
23
23
  #
24
24
 
25
25
  def acceptable?(val)
26
- if val.nil? || val.is_a?(::Protobuf::Message) || val.instance_of?(String)
27
- return true
28
- else
29
- raise TypeError, "Cannot set field : #{name} to value : #{val}"
30
- end
26
+ val.nil? || val.is_a?(String) || val.is_a?(Symbol) || val.is_a?(::Protobuf::Message)
31
27
  end
32
28
 
33
29
  def decode(bytes)
@@ -61,6 +57,7 @@ module Protobuf
61
57
  define_method(field.setter_method_name) do |val|
62
58
  begin
63
59
  field.warn_if_deprecated
60
+ val = "#{val}" if val.is_a?(Symbol)
64
61
 
65
62
  if val.nil?
66
63
  @values.delete(field.name)
@@ -10,15 +10,16 @@ module Protobuf
10
10
  module Rpc
11
11
  module Connectors
12
12
  DEFAULT_OPTIONS = {
13
- :service => nil, # Fully-qualified Service class
14
- :method => nil, # Service method to invoke
15
- :host => '127.0.0.1', # The hostname or address of the service (usually overridden or pre-configured)
16
- :port => '9399', # The port of the service (usually overridden or pre-configured)
17
- :request => nil, # The request object sent by the client
18
- :request_type => nil, # The request type expected by the client
19
- :response_type => nil, # The response type expected by the client
20
- :timeout => 300, # The default timeout for the request, also handled by client.rb
21
- :client_host => nil # The hostname or address of this client
13
+ :service => nil, # Fully-qualified Service class
14
+ :method => nil, # Service method to invoke
15
+ :host => '127.0.0.1', # The hostname or address of the service (usually overridden)
16
+ :port => '9399', # The port of the service (usually overridden or pre-configured)
17
+ :request => nil, # The request object sent by the client
18
+ :request_type => nil, # The request type expected by the client
19
+ :response_type => nil, # The response type expected by the client
20
+ :timeout => 300, # The default timeout for the request, also handled by client.rb
21
+ :client_host => nil, # The hostname or address of this client
22
+ :first_alive_load_balance => false, # Do we want to use check_avail frames before request
22
23
  }
23
24
 
24
25
  class Base
@@ -31,6 +32,11 @@ module Protobuf
31
32
  @options = DEFAULT_OPTIONS.merge(options)
32
33
  end
33
34
 
35
+ def first_alive_load_balance?
36
+ ENV.has_key?("PB_FIRST_ALIVE_LOAD_BALANCE") ||
37
+ options[:first_alive_load_balance]
38
+ end
39
+
34
40
  def send_request
35
41
  raise 'If you inherit a Connector from Base you must implement send_request'
36
42
  end
@@ -64,14 +64,28 @@ module Protobuf
64
64
  # service. The LINGER is set to 0 so we can close immediately in
65
65
  # the event of a timeout
66
66
  def create_socket
67
- server_uri = lookup_server_uri
67
+ socket = nil
68
68
 
69
- socket = zmq_context.socket(::ZMQ::REQ)
70
- socket.setsockopt(::ZMQ::LINGER, 0)
69
+ begin
70
+ server_uri = lookup_server_uri
71
+
72
+ socket = zmq_context.socket(::ZMQ::REQ)
73
+ socket.setsockopt(::ZMQ::LINGER, 0)
74
+
75
+ log_debug { sign_message("Establishing connection: #{server_uri}") }
76
+ zmq_error_check(socket.connect(server_uri), :socket_connect)
77
+ log_debug { sign_message("Connection established to #{server_uri}") }
71
78
 
72
- log_debug { sign_message("Establishing connection: #{server_uri}") }
73
- zmq_error_check(socket.connect(server_uri), :socket_connect)
74
- log_debug { sign_message("Connection established to #{server_uri}") }
79
+ if first_alive_load_balance?
80
+ check_available_response = ""
81
+ zmq_error_check(socket.send_string(::Protobuf::Rpc::Zmq::CHECK_AVAILABLE_MESSAGE), :socket_send_string)
82
+ zmq_error_check(socket.recv_string(check_available_response), :socket_recv_string)
83
+
84
+ if check_available_response == ::Protobuf::Rpc::Zmq::NO_WORKERS_AVAILABLE
85
+ zmq_error_check(socket.close, :socket_close)
86
+ end
87
+ end
88
+ end while socket.try(:socket).nil?
75
89
 
76
90
  socket
77
91
  end
@@ -87,7 +101,7 @@ module Protobuf
87
101
  # to the host and port in the options
88
102
  #
89
103
  def lookup_server_uri
90
- 5.times do
104
+ 50.times do
91
105
  service_directory.all_listings_for(service).each do |listing|
92
106
  host = listing.try(:address)
93
107
  port = listing.try(:port)
@@ -98,7 +112,7 @@ module Protobuf
98
112
  port = options[:port]
99
113
  return "tcp://#{host}:#{port}" if host_alive?(host)
100
114
 
101
- sleep 1
115
+ sleep(1.0/10.0) # not sure why sleeping at all, but should be way less than 1 second
102
116
  end
103
117
 
104
118
  raise "Host not found for service #{service}"
@@ -86,9 +86,16 @@ module Protobuf
86
86
  end
87
87
 
88
88
  def process_frontend
89
- if @idle_workers.any?
90
- frames = read_from_frontend
91
- write_to_backend([@idle_workers.shift, ""] + frames)
89
+ address, _, message, *frames = read_from_frontend
90
+
91
+ if message == ::Protobuf::Rpc::Zmq::CHECK_AVAILABLE_MESSAGE
92
+ if @idle_workers.any?
93
+ write_to_frontend([address, "", ::Protobuf::Rpc::Zmq::WORKERS_AVAILABLE])
94
+ else
95
+ write_to_frontend([address, "", ::Protobuf::Rpc::Zmq::NO_WORKERS_AVAILABLE])
96
+ end
97
+ else
98
+ write_to_backend([@idle_workers.shift, ""] + [address, "", message ] + frames)
92
99
  end
93
100
  end
94
101
 
@@ -6,6 +6,9 @@ module Protobuf
6
6
 
7
7
  ADDRESS_MATCH = /\A\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\z/.freeze
8
8
  WORKER_READY_MESSAGE = "\1"
9
+ CHECK_AVAILABLE_MESSAGE = "\3"
10
+ NO_WORKERS_AVAILABLE = "\4"
11
+ WORKERS_AVAILABLE = "\5"
9
12
 
10
13
  module Util
11
14
  include ::Protobuf::Logger::LogMethods
@@ -1,3 +1,3 @@
1
1
  module Protobuf
2
- VERSION = '3.0.0.rc1'
2
+ VERSION = '3.0.0.rc2'
3
3
  end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  ##
2
4
  # This file is auto-generated. DO NOT EDIT!
3
5
  #
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protobuf
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.rc1
4
+ version: 3.0.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - BJ Neilsen
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-02-19 00:00:00.000000000 Z
14
+ date: 2014-02-24 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport