Sha256: 10a52fcb9b745c3b93ee9277d315143edac17e5cf4c2586ad7aa80b0aa6de0a0

Contents?: true

Size: 1005 Bytes

Versions: 14

Compression:

Stored size: 1005 Bytes

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

module FlakyProxy
  class Connection
    def initialize(client_socket, server, rules)
      @client_socket = client_socket
      @server_socket = nil
      @server = server
      @rules = rules
    end

    def client_socket
      @client_socket
    end

    def server_socket
      @server_socket ||= @server.open_socket
    end

    def shutdown
      @client_socket.close if @client_socket && !@client_socket.closed?
      @server_socket.close if @server_socket && !@server_socket.closed?
      @shutdown = true
    end

    def service
      loop do
        service_one
        break if @shutdown
      end
    end

    def service_one
      request = Request.read_from(client_socket)
      if request.complete?
        rule = @rules.match(request)
        rule.evaluate(request, self)
      else
        shutdown
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
newrelic_rpm-3.9.3.241 test/flaky_proxy/lib/flaky_proxy/connection.rb
newrelic_rpm-3.9.2.239 test/flaky_proxy/lib/flaky_proxy/connection.rb
newrelic_rpm-3.9.1.236 test/flaky_proxy/lib/flaky_proxy/connection.rb
newrelic_rpm-3.9.0.229 test/flaky_proxy/lib/flaky_proxy/connection.rb
newrelic_rpm-3.8.1.221 test/flaky_proxy/lib/flaky_proxy/connection.rb
newrelic_rpm-3.8.0.218 test/flaky_proxy/lib/flaky_proxy/connection.rb
newrelic_rpm-3.7.3.204 test/flaky_proxy/lib/flaky_proxy/connection.rb
newrelic_rpm-3.7.3.199 test/flaky_proxy/lib/flaky_proxy/connection.rb
newrelic_rpm-3.7.2.195 test/flaky_proxy/lib/flaky_proxy/connection.rb
newrelic_rpm-3.7.2.192 test/flaky_proxy/lib/flaky_proxy/connection.rb
newrelic_rpm-3.7.2.190.beta test/flaky_proxy/lib/flaky_proxy/connection.rb
newrelic_rpm-3.7.1.188 test/flaky_proxy/lib/flaky_proxy/connection.rb
newrelic_rpm-3.7.1.182 test/flaky_proxy/lib/flaky_proxy/connection.rb
newrelic_rpm-3.7.1.180 test/flaky_proxy/lib/flaky_proxy/connection.rb