Commits

Michael Granger committed 6a19362

Convert back to rbczmq for modern mongrel2s

  • Participants
  • Parent commits d0e689f

Comments (0)

Files changed (9)

 tnetstring -v0.3.4
 trollop -v2.0
 yajl-ruby -v1.1.0
-zmq -v2.1.4
+rbczmq -v1.7.1
 
 source "https://rubygems.org/"
 
-gem "nokogiri", "~>1.5"
 gem "sequel", "~>4.2"
 gem "tnetstring", "~>0.3"
 gem "yajl-ruby", "~>1.0"
 gem "trollop", "~>2.0"
 gem "sysexits", "~>1.1"
-gem "zmq", "~>2.1"
+gem "rbczmq", "~>1.7"
 gem "loggability", "~>0.5"
 gem "sqlite3", "~>1.3"
+gem "libxml-ruby", "~>2.7"
 
 gem "hoe-mercurial", "~>1.4.0", :group => [:development, :test]
 gem "hoe-highline", "~>0.1.0", :group => [:development, :test]
 	self.dependency 'yajl-ruby',   '~> 1.0'
 	self.dependency 'trollop',     '~> 2.0'
 	self.dependency 'sysexits',    '~> 1.1'
-	self.dependency 'zmq',         '~> 2.1'
-	self.dependency 'loggability', '~> 0.5'
+	self.dependency 'rbczmq',     '~> 1.7'
+	self.dependency 'loggability','~> 0.5'
 	self.dependency 'sqlite3',     '~> 1.3'
 	self.dependency 'libxml-ruby', '~> 2.7'
 

File lib/mongrel2.rb

 # -*- ruby -*-
 #encoding: utf-8
 
-gem 'zmq'
+# Ensure this is used instead of 'zmq' if it's also installed
+gem 'rbczmq'
 
 require 'loggability'
 require 'zmq'

File 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::LINGER, 0 )
+		@response_sock = ctx.socket( :PUB )
+		@response_sock.linger = 0
 		@response_sock.connect( self.pub_addr )
 	end
 

File 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
 

File spec/mongrel2/connection_spec.rb

 		request_sock = double( "request socket" )
 		response_sock = double( "response socket" )
 
-		expect( @ctx ).to receive( :socket ).with( ZMQ::PULL ).and_return( request_sock )
-		expect( request_sock ).to receive( :setsockopt ).with( ZMQ::LINGER, 0 )
+		expect( @ctx ).to receive( :socket ).with( :PULL ).and_return( request_sock )
+		expect( request_sock ).to receive( :linger= ).with( 0 )
 		expect( request_sock ).to receive( :connect ).with( TEST_SEND_SPEC )
 
-		expect( @ctx ).to receive( :socket ).with( ZMQ::PUB ).and_return( response_sock )
-		expect( response_sock ).to receive( :setsockopt ).with( ZMQ::LINGER, 0 )
+		expect( @ctx ).to receive( :socket ).with( :PUB ).and_return( response_sock )
+		expect( response_sock ).to receive( :linger= ).with( 0 )
 		expect( response_sock ).to_not receive( :identity= )
 		expect( response_sock ).to receive( :connect ).with( TEST_RECV_SPEC )
 
 	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, :connect => nil )
 
-			allow( @ctx ).to receive( :socket ).with( ZMQ::PULL ).and_return( @request_sock )
-			allow( @ctx ).to receive( :socket ).with( ZMQ::PUB ).and_return( @response_sock )
+			allow( @ctx ).to receive( :socket ).with( :PULL ).and_return( @request_sock )
+			allow( @ctx ).to receive( :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 )
-			allow( @ctx ).to receive( :socket ).with( ZMQ::PULL ).and_return( request_sock2 )
-			allow( @ctx ).to receive( :socket ).with( ZMQ::PUB ).and_return( response_sock2 )
+			request_sock2 = double( "request socket", :linger= => nil, :connect => nil )
+			response_sock2 = double( "response socket", :linger= => nil, :connect => nil )
+			allow( @ctx ).to receive( :socket ).with( :PULL ).and_return( request_sock2 )
+			allow( @ctx ).to receive( :socket ).with( :PUB ).and_return( response_sock2 )
 
 			duplicate = @conn.dup
 

File spec/mongrel2/control_spec.rb

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

File 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, :connect => nil, :close => nil )
 
-		allow( @ctx ).to receive( :socket ).with( ZMQ::PULL ).and_return( @request_sock )
-		allow( @ctx ).to receive( :socket ).with( ZMQ::PUB ).and_return( @response_sock )
+		allow( @ctx ).to receive( :socket ).with( :PULL ).and_return( @request_sock )
+		allow( @ctx ).to receive( :socket ).with( :PUB ).and_return( @response_sock )
 
 		allow( ZMQ ).to receive( :select ).and_return([ [@request_sock], [], [] ])