gruf 2.2.0 → 2.2.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.
- checksums.yaml +5 -5
- data/CHANGELOG.md +6 -1
- data/README.md +1 -1
- data/gruf.gemspec +2 -2
- data/lib/gruf/client.rb +3 -3
- data/lib/gruf/error.rb +3 -2
- data/lib/gruf/response.rb +9 -9
- data/lib/gruf/server.rb +30 -7
- data/lib/gruf/version.rb +1 -1
- metadata +7 -7
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 | 
            -
             | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: 8527045d1d987962200fe9f93d95d510dc065e13
         | 
| 4 | 
            +
              data.tar.gz: d5d07f8f3b79194510fb4b7d923d1a7d25cc158a
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 40a3edb5d90cb4229344312eab599f9524d3d3e154fafaa6867e8e5958395ff518346e724d13b386f88964840ed48f4dec31f8c58b078f2c48936f90461c65e8
         | 
| 7 | 
            +
              data.tar.gz: 504cce2f076685d662b45f5d6769f748528d1618a83d312f8cef461242936ff4519cbdb99a430eb0cf6613d166d8e70aa2af01f4bc0b29268b18db4c8cb0a2c9
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -2,9 +2,14 @@ Changelog for the gruf gem. This includes internal history before the gem was ma | |
| 2 2 |  | 
| 3 3 | 
             
            ### Pending release
         | 
| 4 4 |  | 
| 5 | 
            +
            ### 2.2.1
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            - Now changes proc title once server is ready to process incoming requests [#44] 
         | 
| 8 | 
            +
            - Gruf now requires gRPC 1.10.x+ due to various fixes and improvements in the gRPC core libraries
         | 
| 9 | 
            +
             | 
| 5 10 | 
             
            ### 2.2.0
         | 
| 6 11 |  | 
| 7 | 
            -
            - Run server in a monitored thread to allow for trapped exits on sigints
         | 
| 12 | 
            +
            - Run server in a monitored thread to allow for trapped exits on sigints [#43]
         | 
| 8 13 |  | 
| 9 14 | 
             
            ### 2.1.1
         | 
| 10 15 |  | 
    
        data/README.md
    CHANGED
    
    | @@ -17,7 +17,7 @@ up fast and efficiently at scale. Some of its features include: | |
| 17 17 | 
             
              still preserving gRPC BadStatus codes
         | 
| 18 18 | 
             
            * Server and client execution timings in responses
         | 
| 19 19 |  | 
| 20 | 
            -
            gruf currently has active support for gRPC 1. | 
| 20 | 
            +
            gruf currently has active support for gRPC 1.10.x+. gruf is compatible and tested with Ruby 2.2-2.5. 
         | 
| 21 21 | 
             
            gruf is also not [Rails](https://github.com/rails/rails)-specific, and can be used in any Ruby framework 
         | 
| 22 22 | 
             
            (such as [Grape](https://github.com/ruby-grape/grape), for instance).
         | 
| 23 23 |  | 
    
        data/gruf.gemspec
    CHANGED
    
    | @@ -36,7 +36,7 @@ Gem::Specification.new do |spec| | |
| 36 36 | 
             
              spec.add_development_dependency 'rake', '~> 10.0'
         | 
| 37 37 | 
             
              spec.add_development_dependency 'pry'
         | 
| 38 38 |  | 
| 39 | 
            -
              spec.add_runtime_dependency 'grpc', '~> 1. | 
| 40 | 
            -
              spec.add_runtime_dependency 'grpc-tools', '~> 1. | 
| 39 | 
            +
              spec.add_runtime_dependency 'grpc', '~> 1.10'
         | 
| 40 | 
            +
              spec.add_runtime_dependency 'grpc-tools', '~> 1.10'
         | 
| 41 41 | 
             
              spec.add_runtime_dependency 'activesupport'
         | 
| 42 42 | 
             
            end
         | 
    
        data/lib/gruf/client.rb
    CHANGED
    
    | @@ -135,13 +135,13 @@ module Gruf | |
| 135 135 | 
             
                #
         | 
| 136 136 | 
             
                # @param [Symbol] call_sig The call signature being executed
         | 
| 137 137 | 
             
                # @param [Object] req (Optional) The protobuf request message to send
         | 
| 138 | 
            -
                # @param [Hash]  | 
| 138 | 
            +
                # @param [Hash] metadata (Optional) A hash of metadata key/values that are transported with the client request
         | 
| 139 139 | 
             
                # @param [Hash] opts (Optional) A hash of options to send to the gRPC request_response method
         | 
| 140 140 | 
             
                #
         | 
| 141 | 
            -
                def execute(call_sig, req,  | 
| 141 | 
            +
                def execute(call_sig, req, metadata, opts = {}, &block)
         | 
| 142 142 | 
             
                  Timer.time do
         | 
| 143 143 | 
             
                    opts[:return_op] = true
         | 
| 144 | 
            -
                    opts[:metadata] =  | 
| 144 | 
            +
                    opts[:metadata] = metadata
         | 
| 145 145 | 
             
                    send(call_sig, req, opts, &block)
         | 
| 146 146 | 
             
                  end
         | 
| 147 147 | 
             
                end
         | 
    
        data/lib/gruf/error.rb
    CHANGED
    
    | @@ -112,10 +112,11 @@ module Gruf | |
| 112 112 | 
             
                ##
         | 
| 113 113 | 
             
                # Ensure all metadata values are strings as HTTP/2 requires string values for transport
         | 
| 114 114 | 
             
                #
         | 
| 115 | 
            +
                # @param [Hash] metadata The existing metadata hash
         | 
| 115 116 | 
             
                # @return [Hash] The newly set metadata
         | 
| 116 117 | 
             
                #
         | 
| 117 | 
            -
                def metadata=( | 
| 118 | 
            -
                  @metadata =  | 
| 118 | 
            +
                def metadata=(metadata)
         | 
| 119 | 
            +
                  @metadata = metadata.map { |k, str| [k, str.to_s] }.to_h
         | 
| 119 120 | 
             
                end
         | 
| 120 121 |  | 
| 121 122 | 
             
                ##
         | 
    
        data/lib/gruf/response.rb
    CHANGED
    
    | @@ -34,16 +34,16 @@ module Gruf | |
| 34 34 | 
             
                ##
         | 
| 35 35 | 
             
                # Initialize a response object with the given gRPC operation
         | 
| 36 36 | 
             
                #
         | 
| 37 | 
            -
                # @param [GRPC::ActiveCall::Operation]  | 
| 37 | 
            +
                # @param [GRPC::ActiveCall::Operation] operation The given operation for the current call
         | 
| 38 38 | 
             
                # @param [Float] execution_time The amount of time that the response took to occur
         | 
| 39 39 | 
             
                #
         | 
| 40 | 
            -
                def initialize( | 
| 41 | 
            -
                  @operation =  | 
| 42 | 
            -
                  @message =  | 
| 43 | 
            -
                  @metadata =  | 
| 44 | 
            -
                  @trailing_metadata =  | 
| 45 | 
            -
                  @deadline =  | 
| 46 | 
            -
                  @cancelled =  | 
| 40 | 
            +
                def initialize(operation, execution_time = nil)
         | 
| 41 | 
            +
                  @operation = operation
         | 
| 42 | 
            +
                  @message = operation.execute
         | 
| 43 | 
            +
                  @metadata = operation.metadata
         | 
| 44 | 
            +
                  @trailing_metadata = operation.trailing_metadata
         | 
| 45 | 
            +
                  @deadline = operation.deadline
         | 
| 46 | 
            +
                  @cancelled = operation.cancelled?
         | 
| 47 47 | 
             
                  @execution_time = execution_time || 0.0
         | 
| 48 48 | 
             
                end
         | 
| 49 49 |  | 
| @@ -53,7 +53,7 @@ module Gruf | |
| 53 53 | 
             
                # @return [Object] The protobuf response message
         | 
| 54 54 | 
             
                #
         | 
| 55 55 | 
             
                def message
         | 
| 56 | 
            -
                  @message ||=  | 
| 56 | 
            +
                  @message ||= @operation.execute
         | 
| 57 57 | 
             
                end
         | 
| 58 58 |  | 
| 59 59 | 
             
                ##
         | 
    
        data/lib/gruf/server.rb
    CHANGED
    
    | @@ -42,6 +42,7 @@ module Gruf | |
| 42 42 | 
             
                  @stop_server = false
         | 
| 43 43 | 
             
                  @stop_server_cv = ConditionVariable.new
         | 
| 44 44 | 
             
                  @stop_server_mu = Monitor.new
         | 
| 45 | 
            +
                  @server_mu = Monitor.new
         | 
| 45 46 | 
             
                  setup
         | 
| 46 47 | 
             
                end
         | 
| 47 48 |  | 
| @@ -49,12 +50,14 @@ module Gruf | |
| 49 50 | 
             
                # @return [GRPC::RpcServer] The GRPC server running
         | 
| 50 51 | 
             
                #
         | 
| 51 52 | 
             
                def server
         | 
| 52 | 
            -
                   | 
| 53 | 
            -
                    @server  | 
| 54 | 
            -
             | 
| 55 | 
            -
             | 
| 53 | 
            +
                  @server_mu.synchronize do
         | 
| 54 | 
            +
                    @server ||= begin
         | 
| 55 | 
            +
                      server = GRPC::RpcServer.new(options)
         | 
| 56 | 
            +
                      @port = server.add_http2_port(options.fetch(:hostname, Gruf.server_binding_url), ssl_credentials)
         | 
| 57 | 
            +
                      @services.each { |s| server.handle(s) }
         | 
| 58 | 
            +
                      server
         | 
| 59 | 
            +
                    end
         | 
| 56 60 | 
             
                  end
         | 
| 57 | 
            -
                  @server
         | 
| 58 61 | 
             
                end
         | 
| 59 62 |  | 
| 60 63 | 
             
                ##
         | 
| @@ -62,6 +65,13 @@ module Gruf | |
| 62 65 | 
             
                #
         | 
| 63 66 | 
             
                # :nocov:
         | 
| 64 67 | 
             
                def start!
         | 
| 68 | 
            +
                  update_proc_title(:starting)
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                  server_thread = Thread.new do
         | 
| 71 | 
            +
                    logger.info { 'Booting gRPC Server...' }
         | 
| 72 | 
            +
                    server.run
         | 
| 73 | 
            +
                  end
         | 
| 74 | 
            +
             | 
| 65 75 | 
             
                  stop_server_thread = Thread.new do
         | 
| 66 76 | 
             
                    loop do
         | 
| 67 77 | 
             
                      break if @stop_server
         | 
| @@ -71,12 +81,14 @@ module Gruf | |
| 71 81 | 
             
                    server.stop
         | 
| 72 82 | 
             
                  end
         | 
| 73 83 |  | 
| 74 | 
            -
                   | 
| 84 | 
            +
                  server.wait_till_running
         | 
| 75 85 | 
             
                  @started = true
         | 
| 76 | 
            -
                   | 
| 86 | 
            +
                  update_proc_title(:serving)
         | 
| 77 87 | 
             
                  stop_server_thread.join
         | 
| 88 | 
            +
                  server_thread.join
         | 
| 78 89 | 
             
                  @started = false
         | 
| 79 90 |  | 
| 91 | 
            +
                  update_proc_title(:stopped)
         | 
| 80 92 | 
             
                  logger.info { 'Goodbye!' }
         | 
| 81 93 | 
             
                end
         | 
| 82 94 | 
             
                # :nocov:
         | 
| @@ -218,5 +230,16 @@ module Gruf | |
| 218 230 | 
             
                  end
         | 
| 219 231 | 
             
                end
         | 
| 220 232 | 
             
                # :nocov:
         | 
| 233 | 
            +
             | 
| 234 | 
            +
                ##
         | 
| 235 | 
            +
                # Updates proc name/title
         | 
| 236 | 
            +
                #
         | 
| 237 | 
            +
                # @param [Symbol] state
         | 
| 238 | 
            +
                #
         | 
| 239 | 
            +
                # :nocov:
         | 
| 240 | 
            +
                def update_proc_title(state)
         | 
| 241 | 
            +
                  Process.setproctitle("gruf #{Gruf::VERSION} -- #{state}")
         | 
| 242 | 
            +
                end
         | 
| 243 | 
            +
                # :nocov:
         | 
| 221 244 | 
             
              end
         | 
| 222 245 | 
             
            end
         | 
    
        data/lib/gruf/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: gruf
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 2.2. | 
| 4 | 
            +
              version: 2.2.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Shaun McCormick
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2018- | 
| 11 | 
            +
            date: 2018-03-14 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         | 
| @@ -58,28 +58,28 @@ dependencies: | |
| 58 58 | 
             
                requirements:
         | 
| 59 59 | 
             
                - - "~>"
         | 
| 60 60 | 
             
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            -
                    version: '1. | 
| 61 | 
            +
                    version: '1.10'
         | 
| 62 62 | 
             
              type: :runtime
         | 
| 63 63 | 
             
              prerelease: false
         | 
| 64 64 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 65 | 
             
                requirements:
         | 
| 66 66 | 
             
                - - "~>"
         | 
| 67 67 | 
             
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            -
                    version: '1. | 
| 68 | 
            +
                    version: '1.10'
         | 
| 69 69 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 70 70 | 
             
              name: grpc-tools
         | 
| 71 71 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 72 | 
             
                requirements:
         | 
| 73 73 | 
             
                - - "~>"
         | 
| 74 74 | 
             
                  - !ruby/object:Gem::Version
         | 
| 75 | 
            -
                    version: '1. | 
| 75 | 
            +
                    version: '1.10'
         | 
| 76 76 | 
             
              type: :runtime
         | 
| 77 77 | 
             
              prerelease: false
         | 
| 78 78 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 79 | 
             
                requirements:
         | 
| 80 80 | 
             
                - - "~>"
         | 
| 81 81 | 
             
                  - !ruby/object:Gem::Version
         | 
| 82 | 
            -
                    version: '1. | 
| 82 | 
            +
                    version: '1.10'
         | 
| 83 83 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 84 84 | 
             
              name: activesupport
         | 
| 85 85 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -158,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 158 158 | 
             
                  version: '0'
         | 
| 159 159 | 
             
            requirements: []
         | 
| 160 160 | 
             
            rubyforge_project: 
         | 
| 161 | 
            -
            rubygems_version: 2. | 
| 161 | 
            +
            rubygems_version: 2.6.13
         | 
| 162 162 | 
             
            signing_key: 
         | 
| 163 163 | 
             
            specification_version: 4
         | 
| 164 164 | 
             
            summary: gRPC Ruby Framework
         |