Commits

Michael Granger committed d55e679

Replace stagnant zmq library with rbczmq.

Comments (0)

Files changed (6)

 tnetstring -v0.3.4
 trollop -v2.0
 yajl-ruby -v1.1.0
-zmq -v2.1.4
+rbczmq -v1.7.1

lib/mongrel2/connection.rb

 		self.log.debug "0mq Context is: %p" % [ ctx ]
 
 		self.log.info "Connecting PULL request socket (%s)" % [ self.sub_addr ]
-		@request_sock = ctx.socket( ZMQ::PULL )
-		@request_sock.setsockopt( ZMQ::LINGER, 0 )
+		@request_sock = ctx.socket( :PULL )
+		@request_sock.linger = 0
 		@request_sock.connect( self.sub_addr )
 
 		self.log.info "Connecting PUB response socket (%s)" % [ self.pub_addr ]
-		@response_sock = ctx.socket( ZMQ::PUB )
-		@response_sock.setsockopt( ZMQ::IDENTITY, self.identifier )
-		@response_sock.setsockopt( ZMQ::LINGER, 0 )
+		@response_sock = ctx.socket( :PUB )
+		@response_sock.identity = self.identifier
+		@response_sock.linger = 0
 		@response_sock.connect( self.pub_addr )
 	end
 

lib/mongrel2/control.rb

 	def initialize( port=DEFAULT_PORT )
 		check_port( port )
 		@ctx = Mongrel2.zmq_context
-		@socket = @ctx.socket( ZMQ::REQ )
-		@socket.setsockopt( ZMQ::LINGER, 0 )
+		@socket = @ctx.socket( :REQ )
+		@socket.linger = 0
 		@socket.connect( port.to_s )
 	end
 

spec/mongrel2/connection_spec.rb

 	include Mongrel2::Config::DSL
 
 	before( :all ) do
-		setup_logging( :fatal )
+		setup_logging()
 	end
 
 	# Ensure 0MQ never actually gets called
 		request_sock = double( "request socket" )
 		response_sock = double( "response socket" )
 
-		@ctx.should_receive( :socket ).with( ZMQ::PULL ).and_return( request_sock )
-		request_sock.should_receive( :setsockopt ).with( ZMQ::LINGER, 0 )
+		@ctx.should_receive( :socket ).with( :PULL ).and_return( request_sock )
+		request_sock.should_receive( :linger= ).with( 0 )
 		request_sock.should_receive( :connect ).with( TEST_SEND_SPEC )
 
-		@ctx.should_receive( :socket ).with( ZMQ::PUB ).and_return( response_sock )
-		response_sock.should_receive( :setsockopt ).with( ZMQ::LINGER, 0 )
-		response_sock.should_receive( :setsockopt ).with( ZMQ::IDENTITY, /^[[:xdigit:]]{40}$/ )
+		@ctx.should_receive( :socket ).with( :PUB ).and_return( response_sock )
+		response_sock.should_receive( :linger= ).with( 0 )
+		response_sock.should_receive( :identity= ).with( /^[[:xdigit:]]{40}$/ )
 		response_sock.should_receive( :connect ).with( TEST_RECV_SPEC )
 
 		@conn.request_sock.should == request_sock
 	context "after a connection has been established" do
 
 		before( :each ) do
-			@request_sock = double( "request socket", :setsockopt => nil, :connect => nil )
-			@response_sock = double( "response socket", :setsockopt => nil, :connect => nil )
+			@request_sock = double( "request socket", :linger= => nil, :connect => nil )
+			@response_sock = double( "response socket", :linger= => nil, :identity= => nil, :connect => nil )
 
-			@ctx.stub( :socket ).with( ZMQ::PULL ).and_return( @request_sock )
-			@ctx.stub( :socket ).with( ZMQ::PUB ).and_return( @response_sock )
+			@ctx.stub( :socket ).with( :PULL ).and_return( @request_sock )
+			@ctx.stub( :socket ).with( :PUB ).and_return( @response_sock )
 
 			@conn.connect
 		end
 		end
 
 		it "doesn't keep its request and response sockets when duped" do
-			request_sock2 = double( "request socket", :setsockopt => nil, :connect => nil )
-			response_sock2 = double( "response socket", :setsockopt => nil, :connect => nil )
-			@ctx.stub( :socket ).with( ZMQ::PULL ).and_return( request_sock2 )
-			@ctx.stub( :socket ).with( ZMQ::PUB ).and_return( response_sock2 )
+			request_sock2 = double( "request socket", :linger= => nil, :connect => nil )
+			response_sock2 = double( "response socket", :linger= => nil, :identity= => nil, :connect => nil )
+			@ctx.stub( :socket ).with( :PULL ).and_return( request_sock2 )
+			@ctx.stub( :socket ).with( :PUB ).and_return( response_sock2 )
 
 			duplicate = @conn.dup
 

spec/mongrel2/control_spec.rb

 
 	before( :each ) do
 		@ctx = double( "ZMQ::Context" )
-		@socket = double( "ZMQ REQ socket", :connect => nil, :setsockopt => nil )
-		@ctx.stub( :socket ).with( ZMQ::REQ ).and_return( @socket )
+		@socket = double( "ZMQ REQ socket", :connect => nil, :linger= => nil )
+		@ctx.stub( :socket ).with( :REQ ).and_return( @socket )
 
 		Mongrel2.instance_variable_set( :@zmq_ctx, @ctx )
 

spec/mongrel2/handler_spec.rb

 	# Ensure 0MQ never actually gets called
 	before( :each ) do
 		@ctx = double( '0mq context', close: nil )
-		@request_sock = double( "request socket", setsockopt: nil, connect: nil, close: nil )
-		@response_sock = double( "response socket", setsockopt: nil, connect: nil, close: nil )
+		@request_sock = double( "request socket", :linger= => nil, :connect => nil, :close => nil )
+		@response_sock = double( "response socket", :linger= => nil, :identity= => nil, :connect => nil, :close => nil )
 
-		@ctx.stub( :socket ).with( ZMQ::PULL ).and_return( @request_sock )
-		@ctx.stub( :socket ).with( ZMQ::PUB ).and_return( @response_sock )
+		@ctx.stub( :socket ).with( :PULL ).and_return( @request_sock )
+		@ctx.stub( :socket ).with( :PUB ).and_return( @response_sock )
 
 		ZMQ.stub( :select ).and_return([ [@request_sock], [], [] ])