Sha256: b33c45a93d46674459fe2698003d4b1529b6c59b3a5793fddcd2a303a9344e0e

Contents?: true

Size: 799 Bytes

Versions: 34

Compression:

Stored size: 799 Bytes

Contents

require 'drb/drb'
DRBURI="druby://localhost:8787"

module DrbMockServer
  extend self

  def start_client
    # JRuby doesn't support fork
    if defined? JRUBY_VERSION
      @server = MockServer.new(2)
      at_exit { @server.stop }
    else
      child_pid = Process.fork do
        start_server
      end
      sleep 1
      at_exit { Process.kill("HUP", child_pid); Process.wait2 }
      DRb.start_service
      @server = DRbObject.new_with_uri(DRBURI)
      sleep 1
    end
    true
  end

  def maybe_start
    start_client unless @server
  end

  def method_missing(meth, *args, &block)
    @server.send(meth, *args, &block)
  end

  def start_server
    server = MockServer.new
    DRb.start_service(DRBURI, server)
    Signal.trap("HUP") { server.stop; exit }
    DRb.thread.join
  end
end

Version data entries

34 entries across 24 versions & 2 rubygems

Version Path
riak-client-1.4.5 spec/support/drb_mock_server.rb
riak-client-1.4.4.1 spec/support/drb_mock_server.rb
riak-client-1.4.4 spec/support/drb_mock_server.rb
riak-client-1.4.3 spec/support/drb_mock_server.rb
riak-client-1.4.2 spec/support/drb_mock_server.rb
riak-client-1.4.1 spec/support/drb_mock_server.rb
riak-client-1.4.0 spec/support/drb_mock_server.rb
riak-client-1.2.0 spec/support/drb_mock_server.rb
riak-client-1.1.1 spec/support/drb_mock_server.rb
riak-client-1.1.0 spec/support/drb_mock_server.rb
riak-client-1.0.5 spec/support/drb_mock_server.rb
riak-client-1.0.3 pkg/riak-client-1.0.2/spec/support/drb_mock_server.rb
riak-client-1.0.3 spec/support/drb_mock_server.rb
riak-client-1.0.3 pkg/riak-client-1.0.0/spec/support/drb_mock_server.rb
riak-client-1.0.3 pkg/riak-client-1.0.1/pkg/riak-client-1.0.0/spec/support/drb_mock_server.rb
riak-client-1.0.3 pkg/riak-client-1.0.1/spec/support/drb_mock_server.rb
riak-client-1.0.3 pkg/riak-client-1.0.2/pkg/riak-client-1.0.0/spec/support/drb_mock_server.rb
riak-client-1.0.3 pkg/riak-client-1.0.2/pkg/riak-client-1.0.1/spec/support/drb_mock_server.rb
riak-client-1.0.3 pkg/riak-client-1.0.2/pkg/riak-client-1.0.1/pkg/riak-client-1.0.0/spec/support/drb_mock_server.rb
riak-client-1.0.2 pkg/riak-client-1.0.0/spec/support/drb_mock_server.rb