Sha256: 5b1b06b2529e598556c6d85d10b9459e0cc0b0e97e650a4a4be59dc89ebdc461

Contents?: true

Size: 820 Bytes

Versions: 4

Compression:

Stored size: 820 Bytes

Contents

# frozen_string_literal: true

module Nonnative
  class GRPCServer < Nonnative::Server
    def initialize(service)
      @server = GRPC::RpcServer.new
      server.handle(svc)

      # Unfortunately gRPC has only one logger so the first server wins.
      GRPC.define_singleton_method(:logger) do
        @logger ||= Logger.new(service.log)
      end

      super(service)
    end

    protected

    def perform_start
      server.add_http2_port("#{proxy.host}:#{proxy.port}", :this_port_is_insecure)
      server.run
    end

    def perform_stop
      server.stop
    end

    def wait_start
      timeout.perform do
        super until server.running?
      end
    end

    def wait_stop
      timeout.perform do
        super until server.stopped?
      end
    end

    private

    attr_reader :server
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nonnative-1.79.0 lib/nonnative/grpc_server.rb
nonnative-1.78.0 lib/nonnative/grpc_server.rb
nonnative-1.77.0 lib/nonnative/grpc_server.rb
nonnative-1.76.0 lib/nonnative/grpc_server.rb