mirror of
https://github.com/valitydev/thrift.git
synced 2024-11-06 18:35:19 +00:00
THRIFT-4358: add unix domain socket option to ruby cross tests
Client: rb This closes #1513
This commit is contained in:
parent
22bd3450c6
commit
9aaf295806
@ -369,11 +369,19 @@ module Thrift
|
|||||||
read_list_end
|
read_list_end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"#{trans.to_s}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class BaseProtocolFactory
|
class BaseProtocolFactory
|
||||||
def get_protocol(trans)
|
def get_protocol(trans)
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"base"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -226,12 +226,19 @@ module Thrift
|
|||||||
size = read_i32
|
size = read_i32
|
||||||
trans.read_all(size)
|
trans.read_all(size)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"binary(#{super.to_s})"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class BinaryProtocolFactory < BaseProtocolFactory
|
class BinaryProtocolFactory < BaseProtocolFactory
|
||||||
def get_protocol(trans)
|
def get_protocol(trans)
|
||||||
return Thrift::BinaryProtocol.new(trans)
|
return Thrift::BinaryProtocol.new(trans)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"binary"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -35,5 +35,13 @@ module Thrift
|
|||||||
BinaryProtocol.new(trans)
|
BinaryProtocol.new(trans)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
if (defined? BinaryProtocolAccelerated)
|
||||||
|
"binary-accel"
|
||||||
|
else
|
||||||
|
"binary"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -345,6 +345,10 @@ module Thrift
|
|||||||
size = read_varint32()
|
size = read_varint32()
|
||||||
trans.read_all(size)
|
trans.read_all(size)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"compact(#{super.to_s})"
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
@ -431,5 +435,9 @@ module Thrift
|
|||||||
def get_protocol(trans)
|
def get_protocol(trans)
|
||||||
CompactProtocol.new(trans)
|
CompactProtocol.new(trans)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"compact"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -768,11 +768,19 @@ module Thrift
|
|||||||
def read_binary
|
def read_binary
|
||||||
read_json_base64
|
read_json_base64
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"json(#{super.to_s})"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class JsonProtocolFactory < BaseProtocolFactory
|
class JsonProtocolFactory < BaseProtocolFactory
|
||||||
def get_protocol(trans)
|
def get_protocol(trans)
|
||||||
return Thrift::JsonProtocol.new(trans)
|
return Thrift::JsonProtocol.new(trans)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"json"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -36,5 +36,9 @@ module Thrift
|
|||||||
@protocol.write_message_begin(name, type, seqid)
|
@protocol.write_message_begin(name, type, seqid)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"multiplexed(#{@service_name=@protocol.to_s})"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -26,6 +26,12 @@ module Thrift
|
|||||||
@protocol_factory = protocol_factory ? protocol_factory : Thrift::BinaryProtocolFactory.new
|
@protocol_factory = protocol_factory ? protocol_factory : Thrift::BinaryProtocolFactory.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def serve; nil; end
|
def serve
|
||||||
|
raise NotImplementedError
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"server(#{@protocol_factory.to_s}(#{@transport_factory.to_s}(#{@server_transport.to_s})))"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -39,5 +39,9 @@ module Thrift
|
|||||||
@server_transport.close
|
@server_transport.close
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"simple(#{super.to_s})"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -71,5 +71,9 @@ module Thrift
|
|||||||
@server_transport.close
|
@server_transport.close
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"threadpool(#{super.to_s})"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -43,5 +43,9 @@ module Thrift
|
|||||||
@server_transport.close
|
@server_transport.close
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"threaded(#{super.to_s})"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -34,4 +34,4 @@ module Thrift
|
|||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -99,11 +99,19 @@ module Thrift
|
|||||||
alias_method :<<, :write
|
alias_method :<<, :write
|
||||||
|
|
||||||
def flush; end
|
def flush; end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"base"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class BaseTransportFactory
|
class BaseTransportFactory
|
||||||
def get_transport(trans)
|
def get_transport(trans)
|
||||||
return trans
|
return trans
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"base"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -104,11 +104,19 @@ module Thrift
|
|||||||
|
|
||||||
@transport.flush
|
@transport.flush
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"buffered(#{@transport.to_s})"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class BufferedTransportFactory < BaseTransportFactory
|
class BufferedTransportFactory < BaseTransportFactory
|
||||||
def get_transport(transport)
|
def get_transport(transport)
|
||||||
return BufferedTransport.new(transport)
|
return BufferedTransport.new(transport)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"buffered"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -99,6 +99,10 @@ module Thrift
|
|||||||
@wbuf = Bytes.empty_byte_buffer
|
@wbuf = Bytes.empty_byte_buffer
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"framed(#{@transport.to_s})"
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def read_frame
|
def read_frame
|
||||||
@ -113,5 +117,9 @@ module Thrift
|
|||||||
def get_transport(transport)
|
def get_transport(transport)
|
||||||
return FramedTransport.new(transport)
|
return FramedTransport.new(transport)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"framed"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -53,5 +53,9 @@ module Thrift
|
|||||||
ensure
|
ensure
|
||||||
@outbuf = Bytes.empty_byte_buffer
|
@outbuf = Bytes.empty_byte_buffer
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"@{self.url}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -35,5 +35,8 @@ module Thrift
|
|||||||
def write(buf); @output.write(Bytes.force_binary_encoding(buf)) end
|
def write(buf); @output.write(Bytes.force_binary_encoding(buf)) end
|
||||||
def close; @input.close; @output.close end
|
def close; @input.close; @output.close end
|
||||||
def to_io; @input end # we're assuming this is used in a IO.select for reading
|
def to_io; @input end # we're assuming this is used in a IO.select for reading
|
||||||
|
def to_s
|
||||||
|
"iostream(input=#{@input.to_s},output=#{@output.to_s})"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -121,5 +121,9 @@ module Thrift
|
|||||||
end
|
end
|
||||||
out.join(" ")
|
out.join(" ")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"memory"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -59,5 +59,10 @@ module Thrift
|
|||||||
end
|
end
|
||||||
|
|
||||||
alias to_io handle
|
alias to_io handle
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"socket(#{@host}:#{@port})"
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -134,8 +134,10 @@ module Thrift
|
|||||||
@handle = nil
|
@handle = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_io
|
alias to_io handle
|
||||||
@handle
|
|
||||||
|
def to_s
|
||||||
|
"socket(#{@host}:#{@port})"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -33,5 +33,9 @@ module Thrift
|
|||||||
socket = TCPServer.new(@host, @port)
|
socket = TCPServer.new(@host, @port)
|
||||||
@handle = OpenSSL::SSL::SSLServer.new(socket, @ssl_context)
|
@handle = OpenSSL::SSL::SSLServer.new(socket, @ssl_context)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"ssl(#{super.to_s})"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -43,5 +43,9 @@ module Thrift
|
|||||||
raise TransportException.new(TransportException::NOT_OPEN, "Could not connect to #{@desc}: #{e}")
|
raise TransportException.new(TransportException::NOT_OPEN, "Could not connect to #{@desc}: #{e}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"ssl(#{super.to_s})"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -56,5 +56,9 @@ module Thrift
|
|||||||
end
|
end
|
||||||
|
|
||||||
alias to_io handle
|
alias to_io handle
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"domain(#{@path})"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -36,5 +36,9 @@ module Thrift
|
|||||||
raise TransportException.new(TransportException::NOT_OPEN, "Could not open UNIX socket at #{@path}")
|
raise TransportException.new(TransportException::NOT_OPEN, "Could not open UNIX socket at #{@path}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"domain(#{@path})"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -29,6 +29,11 @@ describe 'BaseProtocol' do
|
|||||||
describe Thrift::BaseProtocol do
|
describe Thrift::BaseProtocol do
|
||||||
# most of the methods are stubs, so we can ignore them
|
# most of the methods are stubs, so we can ignore them
|
||||||
|
|
||||||
|
it "should provide a reasonable to_s" do
|
||||||
|
@trans.should_receive(:to_s).once.and_return("trans")
|
||||||
|
@prot.to_s.should == "trans"
|
||||||
|
end
|
||||||
|
|
||||||
it "should make trans accessible" do
|
it "should make trans accessible" do
|
||||||
@prot.trans.should eql(@trans)
|
@prot.trans.should eql(@trans)
|
||||||
end
|
end
|
||||||
@ -213,5 +218,9 @@ describe 'BaseProtocol' do
|
|||||||
# returning nil since Protocol is just an abstract class
|
# returning nil since Protocol is just an abstract class
|
||||||
lambda {Thrift::BaseProtocolFactory.new.get_protocol(mock("MockTransport"))}.should raise_error(NotImplementedError)
|
lambda {Thrift::BaseProtocolFactory.new.get_protocol(mock("MockTransport"))}.should raise_error(NotImplementedError)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should provide a reasonable to_s" do
|
||||||
|
Thrift::BaseProtocolFactory.new.to_s.should == "base"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -48,6 +48,10 @@ describe 'BaseTransport' do
|
|||||||
it "should alias << to write" do
|
it "should alias << to write" do
|
||||||
Thrift::BaseTransport.instance_method(:<<).should == Thrift::BaseTransport.instance_method(:write)
|
Thrift::BaseTransport.instance_method(:<<).should == Thrift::BaseTransport.instance_method(:write)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should provide a reasonable to_s" do
|
||||||
|
Thrift::BaseTransport.new.to_s.should == "base"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe Thrift::BaseServerTransport do
|
describe Thrift::BaseServerTransport do
|
||||||
@ -63,9 +67,19 @@ describe 'BaseTransport' do
|
|||||||
transport = mock("Transport")
|
transport = mock("Transport")
|
||||||
Thrift::BaseTransportFactory.new.get_transport(transport).should eql(transport)
|
Thrift::BaseTransportFactory.new.get_transport(transport).should eql(transport)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should provide a reasonable to_s" do
|
||||||
|
Thrift::BaseTransportFactory.new.to_s.should == "base"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe Thrift::BufferedTransport do
|
describe Thrift::BufferedTransport do
|
||||||
|
it "should provide a to_s that describes the encapsulation" do
|
||||||
|
trans = mock("Transport")
|
||||||
|
trans.should_receive(:to_s).and_return("mock")
|
||||||
|
Thrift::BufferedTransport.new(trans).to_s.should == "buffered(mock)"
|
||||||
|
end
|
||||||
|
|
||||||
it "should pass through everything but write/flush/read" do
|
it "should pass through everything but write/flush/read" do
|
||||||
trans = mock("Transport")
|
trans = mock("Transport")
|
||||||
trans.should_receive(:open?).ordered.and_return("+ open?")
|
trans.should_receive(:open?).ordered.and_return("+ open?")
|
||||||
@ -135,6 +149,10 @@ describe 'BaseTransport' do
|
|||||||
Thrift::BufferedTransport.should_receive(:new).with(trans).and_return(btrans)
|
Thrift::BufferedTransport.should_receive(:new).with(trans).and_return(btrans)
|
||||||
Thrift::BufferedTransportFactory.new.get_transport(trans).should == btrans
|
Thrift::BufferedTransportFactory.new.get_transport(trans).should == btrans
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should provide a reasonable to_s" do
|
||||||
|
Thrift::BufferedTransportFactory.new.to_s.should == "buffered"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe Thrift::FramedTransport do
|
describe Thrift::FramedTransport do
|
||||||
@ -142,6 +160,12 @@ describe 'BaseTransport' do
|
|||||||
@trans = mock("Transport")
|
@trans = mock("Transport")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should provide a to_s that describes the encapsulation" do
|
||||||
|
trans = mock("Transport")
|
||||||
|
trans.should_receive(:to_s).and_return("mock")
|
||||||
|
Thrift::FramedTransport.new(trans).to_s.should == "framed(mock)"
|
||||||
|
end
|
||||||
|
|
||||||
it "should pass through open?/open/close" do
|
it "should pass through open?/open/close" do
|
||||||
ftrans = Thrift::FramedTransport.new(@trans)
|
ftrans = Thrift::FramedTransport.new(@trans)
|
||||||
@trans.should_receive(:open?).ordered.and_return("+ open?")
|
@trans.should_receive(:open?).ordered.and_return("+ open?")
|
||||||
@ -247,6 +271,10 @@ describe 'BaseTransport' do
|
|||||||
Thrift::FramedTransport.should_receive(:new).with(trans)
|
Thrift::FramedTransport.should_receive(:new).with(trans)
|
||||||
Thrift::FramedTransportFactory.new.get_transport(trans)
|
Thrift::FramedTransportFactory.new.get_transport(trans)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should provide a reasonable to_s" do
|
||||||
|
Thrift::FramedTransportFactory.new.to_s.should == "framed"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe Thrift::MemoryBufferTransport do
|
describe Thrift::MemoryBufferTransport do
|
||||||
@ -254,6 +282,10 @@ describe 'BaseTransport' do
|
|||||||
@buffer = Thrift::MemoryBufferTransport.new
|
@buffer = Thrift::MemoryBufferTransport.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should provide a reasonable to_s" do
|
||||||
|
@buffer.to_s.should == "memory"
|
||||||
|
end
|
||||||
|
|
||||||
it "should accept a buffer on input and use it directly" do
|
it "should accept a buffer on input and use it directly" do
|
||||||
s = "this is a test"
|
s = "this is a test"
|
||||||
@buffer = Thrift::MemoryBufferTransport.new(s)
|
@buffer = Thrift::MemoryBufferTransport.new(s)
|
||||||
@ -323,6 +355,12 @@ describe 'BaseTransport' do
|
|||||||
@trans = Thrift::IOStreamTransport.new(@input, @output)
|
@trans = Thrift::IOStreamTransport.new(@input, @output)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should provide a reasonable to_s" do
|
||||||
|
@input.should_receive(:to_s).and_return("mock_input")
|
||||||
|
@output.should_receive(:to_s).and_return("mock_output")
|
||||||
|
@trans.to_s.should == "iostream(input=mock_input,output=mock_output)"
|
||||||
|
end
|
||||||
|
|
||||||
it "should be open as long as both input or output are open" do
|
it "should be open as long as both input or output are open" do
|
||||||
@trans.should be_open
|
@trans.should be_open
|
||||||
@input.stub!(:closed?).and_return(true)
|
@input.stub!(:closed?).and_return(true)
|
||||||
|
@ -35,8 +35,12 @@ if defined? Thrift::BinaryProtocolAccelerated
|
|||||||
it "should create a BinaryProtocolAccelerated" do
|
it "should create a BinaryProtocolAccelerated" do
|
||||||
Thrift::BinaryProtocolAcceleratedFactory.new.get_protocol(mock("MockTransport")).should be_instance_of(Thrift::BinaryProtocolAccelerated)
|
Thrift::BinaryProtocolAcceleratedFactory.new.get_protocol(mock("MockTransport")).should be_instance_of(Thrift::BinaryProtocolAccelerated)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should provide a reasonable to_s" do
|
||||||
|
Thrift::BinaryProtocolAcceleratedFactory.new.to_s.should == "binary-accel"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
puts "skipping BinaryProtocolAccelerated spec because it is not defined."
|
puts "skipping BinaryProtocolAccelerated spec because it is not defined."
|
||||||
end
|
end
|
||||||
|
@ -56,11 +56,19 @@ describe 'BinaryProtocol' do
|
|||||||
e.type == Thrift::ProtocolException::BAD_VERSION
|
e.type == Thrift::ProtocolException::BAD_VERSION
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should provide a reasonable to_s" do
|
||||||
|
@prot.to_s.should == "binary(memory)"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe Thrift::BinaryProtocolFactory do
|
describe Thrift::BinaryProtocolFactory do
|
||||||
it "should create a BinaryProtocol" do
|
it "should create a BinaryProtocol" do
|
||||||
Thrift::BinaryProtocolFactory.new.get_protocol(mock("MockTransport")).should be_instance_of(Thrift::BinaryProtocol)
|
Thrift::BinaryProtocolFactory.new.get_protocol(mock("MockTransport")).should be_instance_of(Thrift::BinaryProtocol)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should provide a reasonable to_s" do
|
||||||
|
Thrift::BinaryProtocolFactory.new.to_s.should == "binary"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -127,6 +127,11 @@ describe Thrift::CompactProtocol do
|
|||||||
struct.should == struct2
|
struct.should == struct2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should provide a reasonable to_s" do
|
||||||
|
trans = Thrift::MemoryBufferTransport.new
|
||||||
|
Thrift::CompactProtocol.new(trans).to_s.should == "compact(memory)"
|
||||||
|
end
|
||||||
|
|
||||||
class JankyHandler
|
class JankyHandler
|
||||||
def Janky(i32arg)
|
def Janky(i32arg)
|
||||||
i32arg * 2
|
i32arg * 2
|
||||||
@ -141,3 +146,13 @@ describe Thrift::CompactProtocol do
|
|||||||
"read_#{sym.to_s}"
|
"read_#{sym.to_s}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe Thrift::CompactProtocolFactory do
|
||||||
|
it "should create a CompactProtocol" do
|
||||||
|
Thrift::CompactProtocolFactory.new.get_protocol(mock("MockTransport")).should be_instance_of(Thrift::CompactProtocol)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should provide a reasonable to_s" do
|
||||||
|
Thrift::CompactProtocolFactory.new.to_s.should == "compact"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@ -25,6 +25,10 @@ describe 'Thrift::HTTPClientTransport' do
|
|||||||
before(:each) do
|
before(:each) do
|
||||||
@client = Thrift::HTTPClientTransport.new("http://my.domain.com/path/to/service?param=value")
|
@client = Thrift::HTTPClientTransport.new("http://my.domain.com/path/to/service?param=value")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should provide a reasonable to_s" do
|
||||||
|
@client.to_s == "http://my.domain.com/path/to/service?param=value"
|
||||||
|
end
|
||||||
|
|
||||||
it "should always be open" do
|
it "should always be open" do
|
||||||
@client.should be_open
|
@client.should be_open
|
||||||
|
@ -534,11 +534,19 @@ describe 'JsonProtocol' do
|
|||||||
@trans.write("\"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==\"")
|
@trans.write("\"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==\"")
|
||||||
@prot.read_binary.bytes.to_a.should == (0...256).to_a
|
@prot.read_binary.bytes.to_a.should == (0...256).to_a
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should provide a reasonable to_s" do
|
||||||
|
@prot.to_s.should == "json(memory)"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe Thrift::JsonProtocolFactory do
|
describe Thrift::JsonProtocolFactory do
|
||||||
it "should create a JsonProtocol" do
|
it "should create a JsonProtocol" do
|
||||||
Thrift::JsonProtocolFactory.new.get_protocol(mock("MockTransport")).should be_instance_of(Thrift::JsonProtocol)
|
Thrift::JsonProtocolFactory.new.get_protocol(mock("MockTransport")).should be_instance_of(Thrift::JsonProtocol)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should provide a reasonable to_s" do
|
||||||
|
Thrift::JsonProtocolFactory.new.to_s.should == "json"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -35,6 +35,7 @@ describe 'Thrift::ServerSocket' do
|
|||||||
it "should accept an optional host argument" do
|
it "should accept an optional host argument" do
|
||||||
@socket = Thrift::ServerSocket.new('localhost', 1234)
|
@socket = Thrift::ServerSocket.new('localhost', 1234)
|
||||||
TCPServer.should_receive(:new).with('localhost', 1234)
|
TCPServer.should_receive(:new).with('localhost', 1234)
|
||||||
|
@socket.to_s == "server(localhost:1234)"
|
||||||
@socket.listen
|
@socket.listen
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -75,5 +76,9 @@ describe 'Thrift::ServerSocket' do
|
|||||||
handle.stub!(:closed?).and_return(true)
|
handle.stub!(:closed?).and_return(true)
|
||||||
@socket.should be_closed
|
@socket.should be_closed
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should provide a reasonable to_s" do
|
||||||
|
@socket.to_s.should == "socket(:1234)"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -21,13 +21,30 @@ require 'spec_helper'
|
|||||||
describe 'Server' do
|
describe 'Server' do
|
||||||
|
|
||||||
describe Thrift::BaseServer do
|
describe Thrift::BaseServer do
|
||||||
it "should default to BaseTransportFactory and BinaryProtocolFactory when not specified" do
|
before(:each) do
|
||||||
server = Thrift::BaseServer.new(mock("Processor"), mock("BaseServerTransport"))
|
@processor = mock("Processor")
|
||||||
server.instance_variable_get(:'@transport_factory').should be_an_instance_of(Thrift::BaseTransportFactory)
|
@serverTrans = mock("ServerTransport")
|
||||||
server.instance_variable_get(:'@protocol_factory').should be_an_instance_of(Thrift::BinaryProtocolFactory)
|
@trans = mock("BaseTransport")
|
||||||
|
@prot = mock("BaseProtocol")
|
||||||
|
@server = described_class.new(@processor, @serverTrans, @trans, @prot)
|
||||||
end
|
end
|
||||||
|
|
||||||
# serve is a noop, so can't test that
|
it "should default to BaseTransportFactory and BinaryProtocolFactory when not specified" do
|
||||||
|
@server = Thrift::BaseServer.new(mock("Processor"), mock("BaseServerTransport"))
|
||||||
|
@server.instance_variable_get(:'@transport_factory').should be_an_instance_of(Thrift::BaseTransportFactory)
|
||||||
|
@server.instance_variable_get(:'@protocol_factory').should be_an_instance_of(Thrift::BinaryProtocolFactory)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should not serve" do
|
||||||
|
expect { @server.serve()}.to raise_error(NotImplementedError)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should provide a reasonable to_s" do
|
||||||
|
@serverTrans.should_receive(:to_s).once.and_return("serverTrans")
|
||||||
|
@trans.should_receive(:to_s).once.and_return("trans")
|
||||||
|
@prot.should_receive(:to_s).once.and_return("prot")
|
||||||
|
@server.to_s.should == "server(prot(trans(serverTrans)))"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe Thrift::SimpleServer do
|
describe Thrift::SimpleServer do
|
||||||
@ -40,6 +57,13 @@ describe 'Server' do
|
|||||||
@server = described_class.new(@processor, @serverTrans, @trans, @prot)
|
@server = described_class.new(@processor, @serverTrans, @trans, @prot)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should provide a reasonable to_s" do
|
||||||
|
@serverTrans.should_receive(:to_s).once.and_return("serverTrans")
|
||||||
|
@trans.should_receive(:to_s).once.and_return("trans")
|
||||||
|
@prot.should_receive(:to_s).once.and_return("prot")
|
||||||
|
@server.to_s.should == "simple(server(prot(trans(serverTrans))))"
|
||||||
|
end
|
||||||
|
|
||||||
it "should serve in the main thread" do
|
it "should serve in the main thread" do
|
||||||
@serverTrans.should_receive(:listen).ordered
|
@serverTrans.should_receive(:listen).ordered
|
||||||
@serverTrans.should_receive(:accept).exactly(3).times.and_return(@client)
|
@serverTrans.should_receive(:accept).exactly(3).times.and_return(@client)
|
||||||
@ -69,6 +93,13 @@ describe 'Server' do
|
|||||||
@server = described_class.new(@processor, @serverTrans, @trans, @prot)
|
@server = described_class.new(@processor, @serverTrans, @trans, @prot)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should provide a reasonable to_s" do
|
||||||
|
@serverTrans.should_receive(:to_s).once.and_return("serverTrans")
|
||||||
|
@trans.should_receive(:to_s).once.and_return("trans")
|
||||||
|
@prot.should_receive(:to_s).once.and_return("prot")
|
||||||
|
@server.to_s.should == "threaded(server(prot(trans(serverTrans))))"
|
||||||
|
end
|
||||||
|
|
||||||
it "should serve using threads" do
|
it "should serve using threads" do
|
||||||
@serverTrans.should_receive(:listen).ordered
|
@serverTrans.should_receive(:listen).ordered
|
||||||
@serverTrans.should_receive(:accept).exactly(3).times.and_return(@client)
|
@serverTrans.should_receive(:accept).exactly(3).times.and_return(@client)
|
||||||
@ -97,9 +128,16 @@ describe 'Server' do
|
|||||||
@prot = mock("BaseProtocol")
|
@prot = mock("BaseProtocol")
|
||||||
@client = mock("Client")
|
@client = mock("Client")
|
||||||
@server = described_class.new(@processor, @server_trans, @trans, @prot)
|
@server = described_class.new(@processor, @server_trans, @trans, @prot)
|
||||||
sleep(0.1)
|
sleep(0.15)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should provide a reasonable to_s" do
|
||||||
|
@server_trans.should_receive(:to_s).once.and_return("server_trans")
|
||||||
|
@trans.should_receive(:to_s).once.and_return("trans")
|
||||||
|
@prot.should_receive(:to_s).once.and_return("prot")
|
||||||
|
@server.to_s.should == "threadpool(server(prot(trans(server_trans))))"
|
||||||
|
end
|
||||||
|
|
||||||
it "should serve inside a thread" do
|
it "should serve inside a thread" do
|
||||||
exception_q = @server.instance_variable_get(:@exception_q)
|
exception_q = @server.instance_variable_get(:@exception_q)
|
||||||
described_class.any_instance.should_receive(:serve) do
|
described_class.any_instance.should_receive(:serve) do
|
||||||
|
@ -43,6 +43,7 @@ describe 'Socket' do
|
|||||||
::Socket.should_receive(:new).and_return(mock("Handle", :connect_nonblock => true, :setsockopt => nil))
|
::Socket.should_receive(:new).and_return(mock("Handle", :connect_nonblock => true, :setsockopt => nil))
|
||||||
::Socket.should_receive(:getaddrinfo).with("localhost", 9090, nil, ::Socket::SOCK_STREAM).and_return([[]])
|
::Socket.should_receive(:getaddrinfo).with("localhost", 9090, nil, ::Socket::SOCK_STREAM).and_return([[]])
|
||||||
::Socket.should_receive(:sockaddr_in)
|
::Socket.should_receive(:sockaddr_in)
|
||||||
|
@socket.to_s == "socket(localhost:9090)"
|
||||||
@socket.open
|
@socket.open
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -50,12 +51,18 @@ describe 'Socket' do
|
|||||||
::Socket.should_receive(:new).and_return(mock("Handle", :connect_nonblock => true, :setsockopt => nil))
|
::Socket.should_receive(:new).and_return(mock("Handle", :connect_nonblock => true, :setsockopt => nil))
|
||||||
::Socket.should_receive(:getaddrinfo).with("my.domain", 1234, nil, ::Socket::SOCK_STREAM).and_return([[]])
|
::Socket.should_receive(:getaddrinfo).with("my.domain", 1234, nil, ::Socket::SOCK_STREAM).and_return([[]])
|
||||||
::Socket.should_receive(:sockaddr_in)
|
::Socket.should_receive(:sockaddr_in)
|
||||||
Thrift::Socket.new('my.domain', 1234).open
|
@socket = Thrift::Socket.new('my.domain', 1234).open
|
||||||
|
@socket.to_s == "socket(my.domain:1234)"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should accept an optional timeout" do
|
it "should accept an optional timeout" do
|
||||||
::Socket.stub!(:new)
|
::Socket.stub!(:new)
|
||||||
Thrift::Socket.new('localhost', 8080, 5).timeout.should == 5
|
Thrift::Socket.new('localhost', 8080, 5).timeout.should == 5
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should provide a reasonable to_s" do
|
||||||
|
::Socket.stub!(:new)
|
||||||
|
Thrift::Socket.new('myhost', 8090).to_s.should == "socket(myhost:8090)"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
34
lib/rb/spec/ssl_server_socket_spec.rb
Normal file
34
lib/rb/spec/ssl_server_socket_spec.rb
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
# or more contributor license agreements. See the NOTICE file
|
||||||
|
# distributed with this work for additional information
|
||||||
|
# regarding copyright ownership. The ASF licenses this file
|
||||||
|
# to you under the Apache License, Version 2.0 (the
|
||||||
|
# "License"); you may not use this file except in compliance
|
||||||
|
# with the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing,
|
||||||
|
# software distributed under the License is distributed on an
|
||||||
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
# KIND, either express or implied. See the License for the
|
||||||
|
# specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
require 'spec_helper'
|
||||||
|
require File.expand_path("#{File.dirname(__FILE__)}/socket_spec_shared")
|
||||||
|
|
||||||
|
describe 'SSLServerSocket' do
|
||||||
|
|
||||||
|
describe Thrift::SSLServerSocket do
|
||||||
|
before(:each) do
|
||||||
|
@socket = Thrift::SSLServerSocket.new(1234)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should provide a reasonable to_s" do
|
||||||
|
@socket.to_s.should == "ssl(socket(:1234))"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -70,5 +70,9 @@ describe 'SSLSocket' do
|
|||||||
it "should accept an optional context" do
|
it "should accept an optional context" do
|
||||||
Thrift::SSLSocket.new('localhost', 8080, 5, @context).ssl_context.should == @context
|
Thrift::SSLSocket.new('localhost', 8080, 5, @context).ssl_context.should == @context
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should provide a reasonable to_s" do
|
||||||
|
Thrift::SSLSocket.new('myhost', 8090).to_s.should == "ssl(socket(myhost:8090))"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -42,6 +42,11 @@ describe 'UNIXSocket' do
|
|||||||
::UNIXSocket.stub!(:new)
|
::UNIXSocket.stub!(:new)
|
||||||
Thrift::UNIXSocket.new(@path, 5).timeout.should == 5
|
Thrift::UNIXSocket.new(@path, 5).timeout.should == 5
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should provide a reasonable to_s" do
|
||||||
|
::UNIXSocket.stub!(:new)
|
||||||
|
Thrift::UNIXSocket.new(@path).to_s.should == "domain(#{@path})"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe Thrift::UNIXServerSocket do
|
describe Thrift::UNIXServerSocket do
|
||||||
@ -103,5 +108,9 @@ describe 'UNIXSocket' do
|
|||||||
handle.stub!(:closed?).and_return(true)
|
handle.stub!(:closed?).and_return(true)
|
||||||
@socket.should be_closed
|
@socket.should be_closed
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should provide a reasonable to_s" do
|
||||||
|
@socket.to_s.should == "domain(#{@path})"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -158,6 +158,7 @@ class ExecReporter(TestReporter):
|
|||||||
'client': list(map(re.compile, [
|
'client': list(map(re.compile, [
|
||||||
'[Cc]onnection refused',
|
'[Cc]onnection refused',
|
||||||
'Could not connect to',
|
'Could not connect to',
|
||||||
|
'Could not open UNIX ', # domain socket (rb)
|
||||||
'ECONNREFUSED',
|
'ECONNREFUSED',
|
||||||
'econnrefused', # erl
|
'econnrefused', # erl
|
||||||
'CONNECTION-REFUSED-ERROR', # cl
|
'CONNECTION-REFUSED-ERROR', # cl
|
||||||
|
@ -26,19 +26,24 @@ require 'test_helper'
|
|||||||
require 'thrift'
|
require 'thrift'
|
||||||
require 'thrift_test'
|
require 'thrift_test'
|
||||||
|
|
||||||
|
$domain_socket = nil
|
||||||
$protocolType = "binary"
|
$protocolType = "binary"
|
||||||
$host = "localhost"
|
$host = "localhost"
|
||||||
$port = 9090
|
$port = 9090
|
||||||
$transport = "buffered"
|
$transport = "buffered"
|
||||||
|
|
||||||
ARGV.each do|a|
|
ARGV.each do|a|
|
||||||
if a == "--help"
|
if a == "--help"
|
||||||
puts "Allowed options:"
|
puts "Allowed options:"
|
||||||
puts "\t -h [ --help ] \t produce help message"
|
puts "\t -h [ --help ] \t produce help message"
|
||||||
|
puts "\t--domain-socket arg (=) \t Unix domain socket path - if not empty, host and port are ignored"
|
||||||
puts "\t--host arg (=localhost) \t Host to connect"
|
puts "\t--host arg (=localhost) \t Host to connect"
|
||||||
puts "\t--port arg (=9090) \t Port number to listen"
|
puts "\t--port arg (=9090) \t Port number to listen"
|
||||||
puts "\t--protocol arg (=binary) \t protocol: binary, accel"
|
puts "\t--protocol arg (=binary) \t protocol: accel, binary, compact, json"
|
||||||
puts "\t--transport arg (=buffered) transport: buffered, framed, http"
|
puts "\t--transport arg (=buffered) transport: buffered, framed, http"
|
||||||
exit
|
exit
|
||||||
|
elsif a.start_with?("--domain-socket")
|
||||||
|
$domain_socket = a.split("=")[1]
|
||||||
elsif a.start_with?("--host")
|
elsif a.start_with?("--host")
|
||||||
$host = a.split("=")[1]
|
$host = a.split("=")[1]
|
||||||
elsif a.start_with?("--protocol")
|
elsif a.start_with?("--protocol")
|
||||||
@ -54,7 +59,12 @@ ARGV=[]
|
|||||||
class SimpleClientTest < Test::Unit::TestCase
|
class SimpleClientTest < Test::Unit::TestCase
|
||||||
def setup
|
def setup
|
||||||
unless @socket
|
unless @socket
|
||||||
@socket = Thrift::Socket.new($host, $port)
|
if $domain_socket.to_s.strip.empty?
|
||||||
|
@socket = Thrift::Socket.new($host, $port)
|
||||||
|
else
|
||||||
|
@socket = Thrift::UNIXSocket.new($domain_socket)
|
||||||
|
end
|
||||||
|
|
||||||
if $transport == "buffered"
|
if $transport == "buffered"
|
||||||
transportFactory = Thrift::BufferedTransport.new(@socket)
|
transportFactory = Thrift::BufferedTransport.new(@socket)
|
||||||
elsif $transport == "framed"
|
elsif $transport == "framed"
|
||||||
|
@ -106,19 +106,24 @@ class SimpleHandler
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
protocol = "binary"
|
domain_socket = nil
|
||||||
port = 9090
|
port = 9090
|
||||||
|
protocol = "binary"
|
||||||
|
@protocolFactory = nil
|
||||||
transport = "buffered"
|
transport = "buffered"
|
||||||
@transportFactory = Thrift::BufferedTransportFactory.new
|
@transportFactory = nil
|
||||||
@protocolFactory = Thrift::BinaryProtocolFactory.new
|
|
||||||
ARGV.each do|a|
|
ARGV.each do|a|
|
||||||
if a == "--help"
|
if a == "--help"
|
||||||
puts "Allowed options:"
|
puts "Allowed options:"
|
||||||
puts "\t -h [ --help ] \t produce help message"
|
puts "\t -h [ --help ] \t produce help message"
|
||||||
|
puts "\t--domain-socket arg (=) \t Unix domain socket path - if not empty, port is ignored"
|
||||||
puts "\t--port arg (=9090) \t Port number to listen"
|
puts "\t--port arg (=9090) \t Port number to listen"
|
||||||
puts "\t--protocol arg (=binary) \t protocol: binary, accel"
|
puts "\t--protocol arg (=binary) \t protocol: accel, binary, compact, json"
|
||||||
puts "\t--transport arg (=buffered) transport: buffered, framed, http"
|
puts "\t--transport arg (=buffered) transport: buffered, framed, http"
|
||||||
exit
|
exit
|
||||||
|
elsif a.start_with?("--domain-socket")
|
||||||
|
domain_socket = a.split("=")[1]
|
||||||
elsif a.start_with?("--protocol")
|
elsif a.start_with?("--protocol")
|
||||||
protocol = a.split("=")[1]
|
protocol = a.split("=")[1]
|
||||||
elsif a.start_with?("--transport")
|
elsif a.start_with?("--transport")
|
||||||
@ -128,9 +133,7 @@ ARGV.each do|a|
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if protocol == "binary"
|
if protocol == "binary" || protocol.to_s.strip.empty?
|
||||||
@protocolFactory = Thrift::BinaryProtocolFactory.new
|
|
||||||
elsif protocol == ""
|
|
||||||
@protocolFactory = Thrift::BinaryProtocolFactory.new
|
@protocolFactory = Thrift::BinaryProtocolFactory.new
|
||||||
elsif protocol == "compact"
|
elsif protocol == "compact"
|
||||||
@protocolFactory = Thrift::CompactProtocolFactory.new
|
@protocolFactory = Thrift::CompactProtocolFactory.new
|
||||||
@ -142,9 +145,7 @@ else
|
|||||||
raise 'Unknown protocol type'
|
raise 'Unknown protocol type'
|
||||||
end
|
end
|
||||||
|
|
||||||
if transport == "buffered"
|
if transport == "buffered" || transport.to_s.strip.empty?
|
||||||
@transportFactory = Thrift::BufferedTransportFactory.new
|
|
||||||
elsif transport == ""
|
|
||||||
@transportFactory = Thrift::BufferedTransportFactory.new
|
@transportFactory = Thrift::BufferedTransportFactory.new
|
||||||
elsif transport == "framed"
|
elsif transport == "framed"
|
||||||
@transportFactory = Thrift::FramedTransportFactory.new
|
@transportFactory = Thrift::FramedTransportFactory.new
|
||||||
@ -152,8 +153,17 @@ else
|
|||||||
raise 'Unknown transport type'
|
raise 'Unknown transport type'
|
||||||
end
|
end
|
||||||
|
|
||||||
@handler = SimpleHandler.new
|
@handler = SimpleHandler.new
|
||||||
@processor = Thrift::Test::ThriftTest::Processor.new(@handler)
|
@processor = Thrift::Test::ThriftTest::Processor.new(@handler)
|
||||||
@transport = Thrift::ServerSocket.new(port)
|
@transport = nil
|
||||||
@server = Thrift::ThreadedServer.new(@processor, @transport, @transportFactory, @protocolFactory)
|
if domain_socket.to_s.strip.empty?
|
||||||
|
@transport = Thrift::ServerSocket.new(port)
|
||||||
|
else
|
||||||
|
@transport = Thrift::UNIXServerSocket.new(domain_socket)
|
||||||
|
end
|
||||||
|
|
||||||
|
@server = Thrift::ThreadedServer.new(@processor, @transport, @transportFactory, @protocolFactory)
|
||||||
|
|
||||||
|
puts "Starting TestServer #{@server.to_s}"
|
||||||
@server.serve
|
@server.serve
|
||||||
|
puts "done."
|
||||||
|
@ -373,13 +373,14 @@
|
|||||||
"framed"
|
"framed"
|
||||||
],
|
],
|
||||||
"sockets": [
|
"sockets": [
|
||||||
|
"domain",
|
||||||
"ip"
|
"ip"
|
||||||
],
|
],
|
||||||
"protocols": [
|
"protocols": [
|
||||||
"compact",
|
|
||||||
"binary",
|
"binary",
|
||||||
"json",
|
"binary:accel",
|
||||||
"binary:accel"
|
"compact",
|
||||||
|
"json"
|
||||||
],
|
],
|
||||||
"workdir": "rb/gen-rb"
|
"workdir": "rb/gen-rb"
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user