foreign_actor 0.0.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 89faf69adf1dbaed27a5e726224118e05995d944
4
- data.tar.gz: 02c59476de4b3a665af6ff3e13c983b5a3d3e59a
3
+ metadata.gz: 0520969e30d46a49a78358cdc8e89cdac4d98883
4
+ data.tar.gz: 377f120fabe7cbf6513886d393999301f56e8a1a
5
5
  SHA512:
6
- metadata.gz: c32ee1ebe1b59b8402e1f85a80996ae71d6526e8d859178fd515eaff21f58094854e0a467b5b5e49ab1ec3bb41de9e0f0235ca5b42fa6148eb87fd4769b6070e
7
- data.tar.gz: e4ce0debaf34f31ad5a6870f0f19537cbdceb4eb5b33ff5c95d34bdfb8c75c89448512a3d0f844018a7a9bffebab150b5ff94ed016bd978b79b8149142c55782
6
+ metadata.gz: 4a9763c1da67226679b5a4364f3d6ebda857a50899737d9288a33dd4c7ef647c9050bf1b21625050b19985cb632f890a9c51a4182a3e60eec63aed4c848dc509
7
+ data.tar.gz: 55f9997d7a41f5f5613b901ac73a434fc86f620f10c84867044af394f27eaadb58699587027c6a6f9ba929c148e05c6f2260f8eddf53e63cd8c3405bf3703924
data/Gemfile CHANGED
@@ -4,6 +4,10 @@ gemspec
4
4
 
5
5
  gem 'rake'
6
6
 
7
+ # gem 'ffi-rzmq', github: 'chuckremes/ffi-rzmq'
8
+ # gem 'ffi-rzmq', path: '/Users/schmurfy/Dev/personal/forks/ffi-rzmq'
9
+ # gem 'ffi-rzmq-core', github: 'chuckremes/ffi-rzmq-core'
10
+
7
11
  group(:doc) do
8
12
  gem 'tilt'
9
13
  end
data/bin/puppetmaster.rb CHANGED
@@ -3,17 +3,17 @@ require 'ffi-rxs'
3
3
 
4
4
  class PuppetMaster
5
5
  def initialize(workers_endpoint, client_endpoint)
6
- @context = XS::Context.new
6
+ @context = ZMQ::Context.new
7
7
  @source_id = nil
8
8
 
9
- @workers_socket = @context.socket(XS::XREQ)
10
- @clients_socket = @context.socket(XS::XREP)
9
+ @workers_socket = @context.socket(ZMQ::XREQ)
10
+ @clients_socket = @context.socket(ZMQ::XREP)
11
11
 
12
12
  @workers_socket.bind(workers_endpoint)
13
13
  @clients_socket.bind(client_endpoint)
14
14
 
15
- @control_socket_srv = @context.socket(XS::PAIR)
16
- @control_socket_cl = @context.socket(XS::PAIR)
15
+ @control_socket_srv = @context.socket(ZMQ::PAIR)
16
+ @control_socket_cl = @context.socket(ZMQ::PAIR)
17
17
 
18
18
  addr = "inproc://ctrl"
19
19
  @control_socket_srv.bind(addr)
@@ -25,7 +25,7 @@ class PuppetMaster
25
25
  trap('INT'){ @control_socket_cl.send_string('') }
26
26
  trap('TERM'){ @control_socket_cl.send_string('') }
27
27
 
28
- poller = XS::Poller.new
28
+ poller = ZMQ::Poller.new
29
29
  poller.register_readable(@workers_socket)
30
30
  poller.register_readable(@clients_socket)
31
31
  # control socket
@@ -57,11 +57,11 @@ class PuppetMaster
57
57
  @source_id = msg.shift
58
58
 
59
59
  # send to the other side
60
- handle_xs_err(@workers_socket, :send_string, msg[0], XS::DONTWAIT)
60
+ handle_xs_err(@workers_socket, :send_string, msg[0], ZMQ::DONTWAIT)
61
61
 
62
62
  else
63
- handle_xs_err(@clients_socket, :send_string, @source_id, XS::DONTWAIT | XS::SNDMORE)
64
- handle_xs_err(@clients_socket, :send_string, msg[0], XS::DONTWAIT)
63
+ handle_xs_err(@clients_socket, :send_string, @source_id, ZMQ::DONTWAIT | ZMQ::SNDMORE)
64
+ handle_xs_err(@clients_socket, :send_string, msg[0], ZMQ::DONTWAIT)
65
65
 
66
66
  end
67
67
  end
@@ -73,7 +73,7 @@ private
73
73
  parts = []
74
74
  loop do
75
75
  data = ""
76
- if s.recv_string(data, XS::DONTWAIT) == -1
76
+ if s.recv_string(data, ZMQ::DONTWAIT) == -1
77
77
  raise "error while reading socket: #{}"
78
78
  end
79
79
  parts << data
@@ -88,8 +88,8 @@ private
88
88
 
89
89
  def handle_xs_err(s, method, *args)
90
90
  rc = s.send(method, *args)
91
- unless XS::Util.resultcode_ok?(rc)
92
- raise "error: #{method}: #{XS::Util.error_string}"
91
+ unless ZMQ::Util.resultcode_ok?(rc)
92
+ raise "error: #{method}: #{ZMQ::Util.error_string}"
93
93
  end
94
94
  end
95
95
 
data/bin/router CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'ffi-rxs'
3
+ require 'ffi-rzmq'
4
4
  require 'yaml'
5
5
 
6
- context = XS::Context.new
7
- poller = XS::Poller.new
6
+ context = ZMQ::Context.new
7
+ poller = ZMQ::Poller.new
8
8
 
9
9
  path = nil
10
10
 
@@ -29,8 +29,8 @@ Pipe = Struct.new(:front, :back) do
29
29
  end
30
30
 
31
31
  conf.each do |name, paths|
32
- frontend = context.socket(XS::XREP)
33
- backend = context.socket(XS::XREQ)
32
+ frontend = context.socket(ZMQ::XREP)
33
+ backend = context.socket(ZMQ::XREQ)
34
34
 
35
35
  frontend.bind(paths['front'])
36
36
  backend.bind(paths['back'])
@@ -54,7 +54,7 @@ loop do
54
54
  loop do
55
55
  socket.recv_string(message = "")
56
56
  more = socket.more_parts?
57
- p.back.send_string(message, more ? XS::SNDMORE : 0)
57
+ p.back.send_string(message, more ? ZMQ::SNDMORE : 0)
58
58
  break unless more
59
59
  end
60
60
  next
@@ -63,7 +63,7 @@ loop do
63
63
  loop do
64
64
  socket.recv_string(message = "")
65
65
  more = socket.more_parts?
66
- p.front.send_string(message, more ? XS::SNDMORE : 0)
66
+ p.front.send_string(message, more ? ZMQ::SNDMORE : 0)
67
67
  break unless more
68
68
  end
69
69
  next
data/example/Procfile CHANGED
@@ -1,2 +1,2 @@
1
- master: ruby ../bin/router
1
+ master: bundle exec ruby ../bin/router
2
2
  worker: ruby worker.rb
@@ -14,7 +14,8 @@ Gem::Specification.new do |gem|
14
14
  gem.require_paths = ["lib"]
15
15
  gem.version = ForeignWorker::VERSION
16
16
 
17
- gem.add_dependency 'ffi-rxs', '~> 1.2.1'
17
+ gem.add_dependency 'ffi-rzmq', '~> 1.0.3'
18
+
18
19
  gem.add_dependency 'celluloid', '~> 0.15.0'
19
20
  gem.add_dependency 'msgpack', '~> 0.5.4'
20
21
  end
@@ -72,10 +72,10 @@ module ForeignActor
72
72
  def initialize(endpoint, request_timeout = nil, reactor_name = :xs_reactor)
73
73
  @reactor_name = reactor_name
74
74
  @request_timeout = request_timeout
75
- @socket = Actor[@reactor_name].socket(XS::XREQ)
75
+ @socket = Actor[@reactor_name].socket(ZMQ::XREQ)
76
76
  rc = @socket.connect(endpoint)
77
- unless XS::Util.resultcode_ok?(rc)
78
- raise IOError, "connect failed: #{XS::Util.error_string}"
77
+ unless ZMQ::Util.resultcode_ok?(rc)
78
+ raise IOError, "connect failed: #{ZMQ::Util.error_string}"
79
79
  end
80
80
 
81
81
  end
@@ -9,14 +9,14 @@ module ForeignActor
9
9
  StopLoop = Class.new(RuntimeError)
10
10
 
11
11
  def initialize(context = nil, poller = nil, timers = nil)
12
- @context = context || XS::Context.new
13
- @poller = poller || XS::Poller.new
12
+ @context = context || ZMQ::Context.new
13
+ @poller = poller || ZMQ::Poller.new
14
14
  @waiting_readables = {}
15
15
  @servers = {}
16
16
  @timers = timers || Timers.new
17
17
 
18
- @control_socket_srv = @context.socket(XS::PAIR)
19
- @control_socket_cl = @context.socket(XS::PAIR)
18
+ @control_socket_srv = @context.socket(ZMQ::PAIR)
19
+ @control_socket_cl = @context.socket(ZMQ::PAIR)
20
20
  @control_messages = Array.new
21
21
 
22
22
  addr = "inproc://ctrl"
@@ -77,10 +77,10 @@ module ForeignActor
77
77
  end
78
78
 
79
79
  def serve_actor(endpoint, actor_or_name)
80
- s = socket(XS::XREP)
80
+ s = socket(ZMQ::XREP)
81
81
  rc = s.connect(endpoint)
82
- unless XS::Util.resultcode_ok?(rc)
83
- raise IOError, "connect failed: #{XS::Util.error_string}"
82
+ unless ZMQ::Util.resultcode_ok?(rc)
83
+ raise IOError, "connect failed: #{ZMQ::Util.error_string}"
84
84
  end
85
85
 
86
86
  if @servers.has_key?(s)
@@ -107,8 +107,8 @@ module ForeignActor
107
107
  end
108
108
 
109
109
  rc = @poller.poll(wait_time)
110
- unless XS::Util.resultcode_ok?(rc)
111
- raise IOError, "libxs poll error: #{XS::Util.error_string}"
110
+ unless ZMQ::Util.resultcode_ok?(rc)
111
+ raise IOError, "libxs poll error: #{ZMQ::Util.error_string}"
112
112
  end
113
113
 
114
114
  @poller.readables.each do |s|
@@ -237,7 +237,7 @@ module ForeignActor
237
237
  parts = []
238
238
  loop do
239
239
  data = ""
240
- if s.recv_string(data, XS::DONTWAIT) == -1
240
+ if s.recv_string(data, ZMQ::DONTWAIT) == -1
241
241
  raise "error while reading socket: #{}"
242
242
  end
243
243
  parts << data
@@ -249,16 +249,16 @@ module ForeignActor
249
249
 
250
250
  def send_msg(s, *parts)
251
251
  parts[0...-1].each do |m|
252
- handle_xs_err(s, :send_string, m, XS::DONTWAIT | XS::SNDMORE)
252
+ handle_xs_err(s, :send_string, m, ZMQ::DONTWAIT | ZMQ::SNDMORE)
253
253
  end
254
254
 
255
- handle_xs_err(s, :send_string, parts[-1], XS::DONTWAIT)
255
+ handle_xs_err(s, :send_string, parts[-1], ZMQ::DONTWAIT)
256
256
  end
257
257
 
258
258
  def handle_xs_err(s, method, *args)
259
259
  rc = s.send(method, *args)
260
- unless XS::Util.resultcode_ok?(rc)
261
- raise "error: #{method}: #{XS::Util.error_string}"
260
+ unless ZMQ::Util.resultcode_ok?(rc)
261
+ raise "error: #{method}: #{ZMQ::Util.error_string}"
262
262
  end
263
263
  end
264
264
 
@@ -1,3 +1,3 @@
1
1
  module ForeignWorker
2
- VERSION = "0.0.4"
2
+ VERSION = "1.0.0"
3
3
  end
data/lib/foreign_actor.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'ffi-rxs'
1
+ require 'ffi-rzmq'
2
2
  require 'celluloid'
3
3
 
4
4
  require_relative 'foreign_actor/version'
@@ -2,16 +2,16 @@ require File.expand_path('../../spec_helper', __FILE__)
2
2
 
3
3
  describe 'Reactor' do
4
4
  before do
5
- # @poller = stub('XS::Poller')
6
- # @context = stub('XS::Context')
5
+ # @poller = stub('ZMQ::Poller')
6
+ # @context = stub('ZMQ::Context')
7
7
  @timers = Timers.new
8
8
  end
9
9
 
10
10
  # should "initialize everything" do
11
11
  # # create control sockets
12
12
  # @ctrl = [stub('ServerCtrl'), stub('ClientCtrl')]
13
- # @context.expects(:socket).with(XS::PAIR).returns(@ctrl[1])
14
- # @context.expects(:socket).with(XS::PAIR).returns(@ctrl[0])
13
+ # @context.expects(:socket).with(ZMQ::PAIR).returns(@ctrl[1])
14
+ # @context.expects(:socket).with(ZMQ::PAIR).returns(@ctrl[0])
15
15
 
16
16
  # @ctrl[0].expects(:bind)
17
17
  # @ctrl[1].expects(:connect)
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreign_actor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julien Ammous
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-28 00:00:00.000000000 Z
11
+ date: 2013-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: ffi-rxs
14
+ name: ffi-rzmq
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 1.2.1
19
+ version: 1.0.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: 1.2.1
26
+ version: 1.0.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: celluloid
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  version: '0'
111
111
  requirements: []
112
112
  rubyforge_project:
113
- rubygems_version: 2.0.6
113
+ rubygems_version: 2.1.11
114
114
  signing_key:
115
115
  specification_version: 4
116
116
  summary: Distributed Actors