zoomq 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile CHANGED
@@ -1,5 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
-
5
- gem 'zmachine', path: '../zmachine'
@@ -71,9 +71,9 @@ module ZooMQ
71
71
  "lib/#{name}/protocol.proto" => "protocol.proto",
72
72
  "lib/#{name}/protocol.rb" => "protocol.rb",
73
73
  "lib/#{name}/client.rb" => "client.rb",
74
- "lib/#{name}/console.rb" => "console.rb",
74
+ "#{name}/console.rb" => "console.rb",
75
75
  "#{name}/server.rb" => "server.rb",
76
- "#{name}/protocol/ping_request.rb" => "ping_request.rb",
76
+ "#{name}/server/ping_request.rb" => "ping_request.rb",
77
77
  }.each do |dest, source|
78
78
  puts " * #{dest}"
79
79
  source = File.join(@root, 'templates', "#{source}.tt")
@@ -11,15 +11,18 @@ end
11
11
  module ZooMQ
12
12
  class Console
13
13
  def initialize
14
- $log.level = :info
14
+ ZMachine.logger = $log
15
15
  Thread.new { zmachine }
16
- Ripl.start(binding: binding)
17
16
  end
18
17
 
19
18
  def zmachine
20
19
  ZMachine.run { client }
21
20
  end
22
21
 
22
+ def run
23
+ Ripl.start(binding: binding)
24
+ end
25
+
23
26
  def method_missing(name, *args, &block)
24
27
  result = nil
25
28
  df = @client.send(name, *args, &block)
@@ -30,5 +33,6 @@ module ZooMQ
30
33
  end
31
34
  result
32
35
  end
36
+
33
37
  end
34
38
  end
@@ -21,6 +21,7 @@ module ZooMQ
21
21
  env: Env.mode,
22
22
  })
23
23
 
24
+ ZMachine.logger = $log
24
25
  Signal.register_shutdown_handler { shutdown }
25
26
  @fqdn = ::Socket.gethostbyname(::Socket.gethostname).first
26
27
  @zk = Zookeeper.new(service_name)
@@ -11,7 +11,10 @@ module ZooMQ
11
11
  def receive_data(msg)
12
12
  origin = msg.unwrap
13
13
  request_id = msg.unwrap
14
+ $log.debug("zoomq:request", id: String.from_java_bytes(request_id.data), from: String.from_java_bytes(origin.data))
14
15
  result = handle_msg(msg)
16
+ $log.debug("zoomq:request", result: result.inspect)
17
+ result = ZMsg.new_string_msg(result.class.to_s, result.to_s)
15
18
  result.wrap(request_id)
16
19
  result.wrap(origin)
17
20
  send_data(result)
@@ -21,13 +24,10 @@ module ZooMQ
21
24
  def handle_msg(msg)
22
25
  cls = String.from_java_bytes(msg.pop.data).constantize
23
26
  request = cls.parse(String.from_java_bytes(msg.pop.data))
24
- handle_request(request)
27
+ $log.debug("zoomq:request", cls: cls, request: request, handler: request.respond_to?(:handle))
28
+ request.handle(@server)
25
29
  end
26
30
 
27
- def handle_request(request)
28
- result = request.handle(@server)
29
- ZMsg.new_string_msg(result.class.to_s, result.to_s)
30
- end
31
31
  end
32
32
  end
33
33
  end
@@ -2,8 +2,9 @@
2
2
  *.rbc
3
3
  .bundle
4
4
  .config
5
+ .jbundler
6
+ .user
5
7
  .yardoc
6
- Gemfile.lock
7
8
  InstalledFiles
8
9
  _yardoc
9
10
  coverage
@@ -1,11 +1,9 @@
1
1
  require '<%=config[:name]%>/protocol'
2
2
 
3
3
  module <%=config[:constant_name]%>
4
- module Protocol
5
- class PingRequest
6
- def handle(server)
7
- PingResponse.new
8
- end
4
+ class PingRequest
5
+ def handle(server)
6
+ PingResponse.new
9
7
  end
10
8
  end
11
9
  end
@@ -1,4 +1,4 @@
1
- package <%=config[:name]%>.protocol;
1
+ package <%=config[:name]%>;
2
2
 
3
3
  message PingRequest {
4
4
  }
@@ -2,12 +2,14 @@
2
2
 
3
3
  require 'zoomq/server'
4
4
 
5
+ require '<%=config[:name]%>/protocol'
6
+
5
7
  Dir[File.join(ROOT, '<%=config[:name]%>', 'server', '*.rb')].each do |f|
6
8
  require f
7
9
  end
8
10
 
9
11
  module <%=config[:constant_name]%>
10
- class Server
12
+ class Server < ZooMQ::Server
11
13
 
12
14
  def service_name
13
15
  <%=config[:name].inspect%>
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "zoomq"
5
- spec.version = "0.2.0"
5
+ spec.version = "0.2.1"
6
6
  spec.authors = ["madvertise Mobile Advertising GmbH"]
7
7
  spec.email = ["tech@madvertise.com"]
8
8
  spec.description = %q{ØMQ ROUTER/ROUTER coordinated by Zookeeper}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zoomq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-27 00:00:00.000000000 Z
12
+ date: 2013-08-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: erubis