Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
365 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
CELLULOID_SPECS_LOG_STRATEGY=stderr | ||
CELLULOID_SPECS_LOG_LEVEL=3 | ||
CELLULOID_SPECS_LOG_FILE=log/ci.log | ||
CELLULOID_SPECS_LOG_SYNC=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
CELLULOID_SPECS_LOG_STRATEGY=single | ||
CELLULOID_SPECS_LOG_FILE=log/test.log | ||
CELLULOID_SPECS_LOG_LEVEL=0 | ||
CELLULOID_SPECS_LOG_SYNC=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "culture"] | ||
path = culture | ||
url = http://github.com/celluloid/culture.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,2 @@ | ||
source 'http://rubygems.org' | ||
|
||
gem 'coveralls', require: false | ||
gem 'celluloid', github: 'celluloid/celluloid', branch: 'master' | ||
gem 'transpec', github: 'yujinakayama/transpec', tag: 'v3.1.0' | ||
|
||
# Specify your gem's dependencies in celluloid-zmq.gemspec | ||
gemspec | ||
require File.expand_path("../culture/sync", __FILE__) | ||
Celluloid::Sync::Gemfile[self] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
$CELLULOID_ZMQ_BACKPORTED = false | ||
require "celluloid/zmq" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Celluloid | ||
module ZMQ | ||
ReadableSocket = Socket::Readable | ||
WritableSocket = Socket::Writable | ||
RepSocket = Socket::Rep | ||
ReqSocket = Socket::Req | ||
DealerSocket = Socket::Dealer | ||
RouterSocket = Socket::Router | ||
PushSocket = Socket::Push | ||
PullSocket = Socket::Pull | ||
PubSocket = Socket::Pub | ||
XPubSocket = Socket::XPub | ||
SubSocket = Socket::Sub | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
module Celluloid | ||
module ZMQ | ||
class Socket | ||
extend Forwardable | ||
def_delegator ZMQ, :result_ok? | ||
# Create a new socket | ||
def initialize(type) | ||
@socket = Celluloid::ZMQ.context.socket ::ZMQ.const_get(type.to_s.upcase) | ||
@linger = 0 | ||
end | ||
attr_reader :linger | ||
|
||
# Connect to the given 0MQ address | ||
# Address should be in the form: tcp://1.2.3.4:5678/ | ||
def connect(addr) | ||
unless result_ok? @socket.connect addr | ||
raise IOError, "error connecting to #{addr}: #{::ZMQ::Util.error_string}" | ||
end | ||
true | ||
end | ||
|
||
def linger=(value) | ||
@linger = value || -1 | ||
|
||
unless result_ok? @socket.setsockopt(::ZMQ::LINGER, value) | ||
raise IOError, "couldn't set linger: #{::ZMQ::Util.error_string}" | ||
end | ||
end | ||
|
||
def identity=(value) | ||
unless result_ok? @socket.setsockopt(::ZMQ::IDENTITY, "#{value}") | ||
raise IOError, "couldn't set identity: #{::ZMQ::Util.error_string}" | ||
end | ||
#de @socket.identity = value | ||
end | ||
|
||
def identity | ||
#de @socket.identity | ||
get(::ZMQ::IDENTITY) | ||
end | ||
|
||
def set(option, value, length = nil) | ||
unless result_ok? @socket.setsockopt(option, value, length) | ||
raise IOError, "couldn't set value for option #{option}: #{::ZMQ::Util.error_string}" | ||
end | ||
end | ||
|
||
def get(option) | ||
option_value = [] | ||
|
||
unless result_ok? @socket.getsockopt(option, option_value) | ||
raise IOError, "couldn't get value for option #{option}: #{::ZMQ::Util.error_string}" | ||
end | ||
|
||
option_value[0] | ||
end | ||
|
||
# Bind to the given 0MQ address | ||
# Address should be in the form: tcp://1.2.3.4:5678/ | ||
def bind(addr) | ||
unless result_ok? @socket.bind(addr) | ||
raise IOError, "couldn't bind to #{addr}: #{::ZMQ::Util.error_string}" | ||
end | ||
end | ||
|
||
# Close the socket | ||
def close | ||
@socket.close | ||
end | ||
|
||
# Hide ffi-rzmq internals | ||
alias_method :inspect, :to_s | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
module Celluloid | ||
module ZMQ | ||
class Socket | ||
# Readable 0MQ sockets have a read method | ||
module Readable | ||
extend Forwardable | ||
def_delegator ZMQ, :result_ok? | ||
|
||
# always set LINGER on readable sockets | ||
def bind(addr) | ||
self.linger = @linger | ||
super(addr) | ||
end | ||
|
||
def connect(addr) | ||
self.linger = @linger | ||
super(addr) | ||
end | ||
|
||
# Read a message from the socket | ||
def read(buffer = '') | ||
ZMQ.wait_readable(@socket) if ZMQ.evented? | ||
|
||
unless result_ok? @socket.recv_string buffer | ||
raise IOError, "error receiving ZMQ string: #{::ZMQ::Util.error_string}" | ||
end | ||
buffer | ||
end | ||
|
||
# Multiparts message ? | ||
def_delegator :@socket, :more_parts? | ||
|
||
# Reads a multipart message, stores it into the given buffer and returns | ||
# the buffer. | ||
def read_multipart(buffer = []) | ||
ZMQ.wait_readable(@socket) if ZMQ.evented? | ||
|
||
unless result_ok? @socket.recv_strings buffer | ||
raise IOError, "error receiving ZMQ string: #{::ZMQ::Util.error_string}" | ||
end | ||
buffer | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.