zoomq 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +32 -0
- data/Rakefile +1 -0
- data/bin/zoomq +6 -0
- data/lib/zoomq/cli.rb +95 -0
- data/lib/zoomq/client.rb +58 -0
- data/lib/zoomq/handler.rb +13 -0
- data/lib/zoomq/jeromq-0.3.0-20130721.175323-20.jar +0 -0
- data/lib/zoomq/server/request_handler.rb +34 -0
- data/lib/zoomq/server/worker.rb +36 -0
- data/lib/zoomq/server.rb +38 -0
- data/lib/zoomq/zookeeper.rb +67 -0
- data/templates/Gemfile.tt +19 -0
- data/templates/LICENSE.txt.tt +22 -0
- data/templates/README.md.tt +29 -0
- data/templates/Rakefile.tt +1 -0
- data/templates/binwrapper.tt +10 -0
- data/templates/client.rb.tt +25 -0
- data/templates/config.yml.tt +3 -0
- data/templates/console.rb.tt +29 -0
- data/templates/console.tt +10 -0
- data/templates/gemspec.tt +19 -0
- data/templates/gitignore.tt +17 -0
- data/templates/ping_request.rb.tt +9 -0
- data/templates/production.yml.tt +3 -0
- data/templates/protocol.proto.tt +7 -0
- data/templates/protocol.rb.tt +4 -0
- data/templates/rspec.tt +2 -0
- data/templates/server.rb.tt +27 -0
- data/templates/staging.yml.tt +1 -0
- data/templates/testing.yml.tt +1 -0
- data/zoomq.gemspec +24 -0
- metadata +178 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Benedikt Böhm
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# ZooMQ
|
2
|
+
|
3
|
+
ZooMQ is an abstraction on top of ZeroMQ sockets and Zookeeper to enable
|
4
|
+
completely transparant N-to-N communication between clients and servers.
|
5
|
+
|
6
|
+
ZooMQ uses ROUTER sockets exclusively and does round-robin between all
|
7
|
+
available servers.
|
8
|
+
|
9
|
+
Google Protocol Buffers are used as wire-format and ZooMQ will transparantly
|
10
|
+
encode and decode your requests.
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Add this line to your application's Gemfile:
|
15
|
+
|
16
|
+
gem 'zoomq'
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install zoomq
|
25
|
+
|
26
|
+
## Contributing
|
27
|
+
|
28
|
+
1. Fork it
|
29
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
30
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
31
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
32
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/zoomq
ADDED
data/lib/zoomq/cli.rb
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'erubis'
|
2
|
+
require 'mixlib/cli'
|
3
|
+
|
4
|
+
module ZooMQ
|
5
|
+
class CLI
|
6
|
+
include Mixlib::CLI
|
7
|
+
|
8
|
+
option :help,
|
9
|
+
:short => '-h',
|
10
|
+
:long => '--help',
|
11
|
+
:description => "Show this message",
|
12
|
+
:on => :tail,
|
13
|
+
:boolean => true,
|
14
|
+
:show_options => true,
|
15
|
+
:exit => 0
|
16
|
+
|
17
|
+
option :author,
|
18
|
+
:short => '-a',
|
19
|
+
:long => '--author',
|
20
|
+
:description => 'Gem author',
|
21
|
+
:default => `git config user.name`.chomp
|
22
|
+
|
23
|
+
option :email,
|
24
|
+
:short => '-e',
|
25
|
+
:long => '--email',
|
26
|
+
:description => 'Author E-Mail',
|
27
|
+
:default => `git config user.email`.chomp
|
28
|
+
|
29
|
+
def initialize
|
30
|
+
super
|
31
|
+
parse_options
|
32
|
+
puts config.inspect
|
33
|
+
@root = File.expand_path('../../..', __FILE__)
|
34
|
+
end
|
35
|
+
|
36
|
+
def run
|
37
|
+
self.__send__(ARGV.shift, *ARGV)
|
38
|
+
end
|
39
|
+
|
40
|
+
def generate(name)
|
41
|
+
if File.exist?(name)
|
42
|
+
puts "!!! #{name} already exists"
|
43
|
+
exit(1)
|
44
|
+
end
|
45
|
+
|
46
|
+
puts ">>> Generating ZooMQ skeleton for #{name}"
|
47
|
+
|
48
|
+
constant_name = name.split('_').map{|p| p[0..0].upcase + p[1..-1] }.join
|
49
|
+
constant_name = constant_name.split('-').map{|q| q[0..0].upcase + q[1..-1] }.join('::') if constant_name =~ /-/
|
50
|
+
constant_array = constant_name.split('::')
|
51
|
+
|
52
|
+
config.merge!({
|
53
|
+
name: name,
|
54
|
+
constant_name: constant_name,
|
55
|
+
constant_array: constant_array,
|
56
|
+
})
|
57
|
+
|
58
|
+
{
|
59
|
+
"Gemfile" => "Gemfile",
|
60
|
+
"Rakefile" => "Rakefile",
|
61
|
+
"LICENSE.txt" => "LICENSE.txt",
|
62
|
+
"README.md" => "README.md",
|
63
|
+
".gitignore" => "gitignore",
|
64
|
+
"#{name}.gemspec" => "gemspec",
|
65
|
+
"bin/#{name}" => "binwrapper",
|
66
|
+
"bin/#{name}-console" => "console",
|
67
|
+
"config.yml" => "config.yml",
|
68
|
+
"config/mixins/production.yml" => "production.yml",
|
69
|
+
"config/mixins/staging.yml" => "staging.yml",
|
70
|
+
"config/mixins/testing.yml" => "testing.yml",
|
71
|
+
"lib/#{name}/protocol.proto" => "protocol.proto",
|
72
|
+
"lib/#{name}/protocol.rb" => "protocol.rb",
|
73
|
+
"lib/#{name}/client.rb" => "client.rb",
|
74
|
+
"lib/#{name}/console.rb" => "console.rb",
|
75
|
+
"#{name}/server.rb" => "server.rb",
|
76
|
+
"#{name}/server/ping_request.rb" => "ping_request.rb",
|
77
|
+
}.each do |dest, source|
|
78
|
+
puts " * #{dest}"
|
79
|
+
source = File.join(@root, 'templates', "#{source}.tt")
|
80
|
+
dest = File.join(name, dest)
|
81
|
+
FileUtils.mkdir_p(File.dirname(dest))
|
82
|
+
input = File.read(source)
|
83
|
+
eruby = Erubis::Eruby.new(input)
|
84
|
+
output = File.open(dest, "w")
|
85
|
+
output.write(eruby.result(binding()))
|
86
|
+
output.close
|
87
|
+
end
|
88
|
+
|
89
|
+
Dir.chdir(name) do
|
90
|
+
puts ">>> Installing dependencies"
|
91
|
+
system("bundle install")
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
data/lib/zoomq/client.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'zoomq/jeromq-0.3.0-20130721.175323-20.jar'
|
4
|
+
java_import org.zeromq.ZMQ
|
5
|
+
java_import org.zeromq.ZContext
|
6
|
+
java_import org.zeromq.ZMsg
|
7
|
+
java_import org.zeromq.ZFrame
|
8
|
+
|
9
|
+
require 'zoomq/zookeeper'
|
10
|
+
|
11
|
+
module ZooMQ
|
12
|
+
class ServerUnavailable < StandardError; end
|
13
|
+
|
14
|
+
class Client
|
15
|
+
|
16
|
+
attr_reader :servers
|
17
|
+
|
18
|
+
def initialize(service_name, zookeeper_uri, log)
|
19
|
+
@zk = Zookeeper.new("#{zookeeper_uri}/#{service_name}")
|
20
|
+
@ctx = ZContext.new
|
21
|
+
@socket = @ctx.create_socket(ZMQ::ROUTER)
|
22
|
+
@socket.identity = SecureRandom.uuid.to_java_bytes
|
23
|
+
watch
|
24
|
+
refresh
|
25
|
+
end
|
26
|
+
|
27
|
+
def watch
|
28
|
+
@zk.watch { refresh }
|
29
|
+
end
|
30
|
+
|
31
|
+
def refresh
|
32
|
+
@servers = @zk.servers
|
33
|
+
@servers.each do |server|
|
34
|
+
@socket.connect("tcp://#{server}")
|
35
|
+
sleep(0.1)
|
36
|
+
end
|
37
|
+
@cycle = @servers.cycle
|
38
|
+
end
|
39
|
+
|
40
|
+
def handle(request)
|
41
|
+
if @servers.empty?
|
42
|
+
raise ServerUnavailable.new("no servers are online, please try again later")
|
43
|
+
end
|
44
|
+
|
45
|
+
server = @cycle.next
|
46
|
+
|
47
|
+
msg = ZMsg.new_string_msg(request.class.to_s, request.to_s)
|
48
|
+
msg.wrap(ZFrame.new(server))
|
49
|
+
msg.send(@socket)
|
50
|
+
|
51
|
+
msg = ZMsg.recvMsg(@socket)
|
52
|
+
msg.unwrap
|
53
|
+
cls = String.from_java_bytes(msg.pop.data).constantize
|
54
|
+
cls.parse(String.from_java_bytes(msg.pop.data))
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
Binary file
|
@@ -0,0 +1,34 @@
|
|
1
|
+
java_import org.zeromq.ZMsg
|
2
|
+
|
3
|
+
require 'zoomq/handler'
|
4
|
+
|
5
|
+
module ZooMQ
|
6
|
+
class Server
|
7
|
+
class RequestHandler < Handler
|
8
|
+
def handle(zloop, poller, worker)
|
9
|
+
@server = worker.server
|
10
|
+
origin, msg = recv_msg(poller.socket)
|
11
|
+
result = handle_msg(msg)
|
12
|
+
result.wrap(origin)
|
13
|
+
result.send(poller.socket)
|
14
|
+
return 0
|
15
|
+
end
|
16
|
+
|
17
|
+
def recv_msg(socket)
|
18
|
+
msg = ZMsg.recvMsg(socket)
|
19
|
+
[msg.unwrap, msg]
|
20
|
+
end
|
21
|
+
|
22
|
+
def handle_msg(msg)
|
23
|
+
cls = String.from_java_bytes(msg.pop.data).constantize
|
24
|
+
request = cls.parse(String.from_java_bytes(msg.pop.data))
|
25
|
+
handle_request(request)
|
26
|
+
end
|
27
|
+
|
28
|
+
def handle_request(request)
|
29
|
+
result = request.handle(@server)
|
30
|
+
ZMsg.new_string_msg(result.class.to_s, result.to_s)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
java_import org.zeromq.ZMQ
|
2
|
+
java_import org.zeromq.ZContext
|
3
|
+
java_import org.zeromq.ZLoop
|
4
|
+
|
5
|
+
require 'zoomq/server/request_handler'
|
6
|
+
|
7
|
+
module ZooMQ
|
8
|
+
class Server
|
9
|
+
class Worker
|
10
|
+
|
11
|
+
attr_reader :server
|
12
|
+
|
13
|
+
def initialize(server)
|
14
|
+
@server = server
|
15
|
+
@zloop = ZLoop.new
|
16
|
+
@zloop.verbose(true)
|
17
|
+
initialize_socket
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize_socket
|
21
|
+
@socket = @server.create_socket(ZMQ::ROUTER)
|
22
|
+
@port = @socket.bind("tcp://*:*")
|
23
|
+
RequestHandler.new(@socket).register(@zloop, self)
|
24
|
+
Thread.current.name = "#{@server.fqdn}:#{@port}"
|
25
|
+
@socket.identity = Thread.current[:name].to_java_bytes
|
26
|
+
end
|
27
|
+
|
28
|
+
def run
|
29
|
+
@server.log.info("pubdater:worker", run: true, announce: @socket.identity)
|
30
|
+
@server.announce(@socket.identity)
|
31
|
+
@zloop.start
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/zoomq/server.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'zoomq/jeromq-0.3.0-20130721.175323-20.jar'
|
4
|
+
java_import org.zeromq.ZMQ
|
5
|
+
|
6
|
+
require 'forwardable'
|
7
|
+
|
8
|
+
require 'zoomq/zookeeper'
|
9
|
+
require 'zoomq/server/worker'
|
10
|
+
|
11
|
+
module ZooMQ
|
12
|
+
class Server
|
13
|
+
|
14
|
+
extend Forwardable
|
15
|
+
def_delegators :@zk, :globals, :locals, :announce
|
16
|
+
def_delegators :@ctx, :create_socket
|
17
|
+
|
18
|
+
attr_reader :log, :fqdn, :port
|
19
|
+
|
20
|
+
def initialize(service_name, zookeeper_uri, log)
|
21
|
+
Signal.register_shutdown_handler { shutdown }
|
22
|
+
@log = log
|
23
|
+
@zk = Zookeeper.new("#{zookeeper_uri}/#{service_name}")
|
24
|
+
@ctx = ZContext.new
|
25
|
+
@fqdn = Socket.gethostbyname(Socket.gethostname).first
|
26
|
+
end
|
27
|
+
|
28
|
+
def run
|
29
|
+
Worker.new(self).run
|
30
|
+
end
|
31
|
+
|
32
|
+
def shutdown
|
33
|
+
@ctx.destroy if @ctx
|
34
|
+
@zk.close if @zk
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'multi_json'
|
2
|
+
require 'zk'
|
3
|
+
|
4
|
+
module ZooMQ
|
5
|
+
class Zookeeper
|
6
|
+
|
7
|
+
attr_reader :globals
|
8
|
+
attr_reader :locals
|
9
|
+
|
10
|
+
def initialize(uri)
|
11
|
+
@zk = ZK.new(uri)
|
12
|
+
@zk.mkdir_p("/alive")
|
13
|
+
@globals = KeySpace.new(:global, @zk)
|
14
|
+
end
|
15
|
+
|
16
|
+
def announce(identity)
|
17
|
+
@locals = KeySpace.new(identity, @zk)
|
18
|
+
path = "/alive/#{identity}"
|
19
|
+
@zk.block_until_node_deleted(path) if @zk.exists?(path)
|
20
|
+
@zk.create(path, mode: :ephemeral)
|
21
|
+
end
|
22
|
+
|
23
|
+
def close
|
24
|
+
@zk.close!
|
25
|
+
end
|
26
|
+
|
27
|
+
def watch(&block)
|
28
|
+
@zk.register('/alive', &block)
|
29
|
+
servers
|
30
|
+
end
|
31
|
+
|
32
|
+
def servers
|
33
|
+
@zk.children('/alive', watch: true)
|
34
|
+
end
|
35
|
+
|
36
|
+
class KeySpace
|
37
|
+
|
38
|
+
def initialize(type, zk)
|
39
|
+
@type, @zk = type, zk
|
40
|
+
end
|
41
|
+
|
42
|
+
def path_for(key)
|
43
|
+
"/#{@type}/#{key}"
|
44
|
+
end
|
45
|
+
|
46
|
+
def get(key)
|
47
|
+
value = @zk.get(path_for(key)) rescue nil
|
48
|
+
MultiJson.load(value.first) rescue nil
|
49
|
+
end
|
50
|
+
|
51
|
+
alias :[] :get
|
52
|
+
|
53
|
+
def set(key, value)
|
54
|
+
@zk.create("/#{@type}", ignore: :node_exists)
|
55
|
+
value = MultiJson.dump(value)
|
56
|
+
if !@zk.create(path_for(key), value, ignore: :node_exists)
|
57
|
+
@zk.set(path_for(key), value)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
alias :[]= :set
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'jbundler'
|
4
|
+
|
5
|
+
gemspec
|
6
|
+
|
7
|
+
gem 'zoomq'
|
8
|
+
|
9
|
+
group :development, :test do
|
10
|
+
gem "awesome_print"
|
11
|
+
gem "brice"
|
12
|
+
gem "fuubar"
|
13
|
+
gem "rake"
|
14
|
+
gem "reek"
|
15
|
+
gem "ripl"
|
16
|
+
gem "rspec"
|
17
|
+
gem "simplecov"
|
18
|
+
gem "yard"
|
19
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) <%=Time.now.year%> <%=config[:author]%>
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# <%=config[:constant_name]%>
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem '<%=config[:name]%>'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install <%=config[:name]%>
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
@@ -0,0 +1 @@
|
|
1
|
+
require "madvertise/tasks"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'forwardable'
|
4
|
+
require 'zoomq/client'
|
5
|
+
|
6
|
+
require '<%=config[:name]%>/protocol'
|
7
|
+
|
8
|
+
module <%=config[:constant_name]%>
|
9
|
+
class Client
|
10
|
+
|
11
|
+
extend Forwardable
|
12
|
+
|
13
|
+
def initialize(zookeeper, log)
|
14
|
+
@client = ZooMQ::Client.new(<%=config[:name].inspect%>, zookeeper, log)
|
15
|
+
end
|
16
|
+
|
17
|
+
def_delegators :@client, :servers
|
18
|
+
|
19
|
+
def ping
|
20
|
+
request = PingRequest.new
|
21
|
+
@client.handle(request)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'ap'
|
2
|
+
require 'irb'
|
3
|
+
require 'ripl'
|
4
|
+
require 'forwardable'
|
5
|
+
|
6
|
+
require '<%=config[:name]%>/client'
|
7
|
+
|
8
|
+
Ripl::Shell.class_eval do
|
9
|
+
def format_result(result)
|
10
|
+
ap(result)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module <%=config[:constant_name]%>
|
15
|
+
class Console
|
16
|
+
|
17
|
+
extend Forwardable
|
18
|
+
def initialize
|
19
|
+
$log.level = :info
|
20
|
+
@client = Client.new($conf.zookeeper)
|
21
|
+
Ripl.start(binding: binding)
|
22
|
+
end
|
23
|
+
|
24
|
+
def method_missing(name, *args, &block)
|
25
|
+
@client.__send__(name, *args, &block)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = <%=config[:name].inspect%>
|
5
|
+
spec.version = "0.1.0"
|
6
|
+
spec.authors = [<%=config[:author].inspect%>]
|
7
|
+
spec.email = [<%=config[:email].inspect%>]
|
8
|
+
spec.description = %q{TODO: Write a gem description}
|
9
|
+
spec.summary = %q{TODO: Write a gem summary}
|
10
|
+
spec.homepage = ""
|
11
|
+
spec.license = "MIT"
|
12
|
+
|
13
|
+
spec.files = `git ls-files`.split($/)
|
14
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
15
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
16
|
+
spec.require_paths = ["lib"]
|
17
|
+
|
18
|
+
spec.add_dependency "zoomq"
|
19
|
+
end
|
data/templates/rspec.tt
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'zoomq/server'
|
4
|
+
|
5
|
+
Dir[File.join(ROOT, '<%=config[:name]%>', 'server', '*.rb')].each do |f|
|
6
|
+
require f
|
7
|
+
end
|
8
|
+
|
9
|
+
module <%=config[:constant_name]%>
|
10
|
+
class Server
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
$log.info("<%=config[:name]%>:initialize #{RUBY_DESCRIPTION}")
|
14
|
+
$log.info("<%=config[:name]%>:initialize", {
|
15
|
+
env: Env.mode,
|
16
|
+
})
|
17
|
+
|
18
|
+
@server = ZooMQ::Server.new(<%=config[:name].inspect%>, $conf.zookeeper, $log)
|
19
|
+
end
|
20
|
+
|
21
|
+
def run
|
22
|
+
$log.info("<%=config[:name]%>:run")
|
23
|
+
@server.run
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
log_level: INFO
|
@@ -0,0 +1 @@
|
|
1
|
+
log_backend: document
|
data/zoomq.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "zoomq"
|
5
|
+
spec.version = "0.1.0"
|
6
|
+
spec.authors = ["madvertise Mobile Advertising GmbH"]
|
7
|
+
spec.email = ["tech@madvertise.com"]
|
8
|
+
spec.description = %q{ØMQ ROUTER/ROUTER coordinated by Zookeeper}
|
9
|
+
spec.summary = %q{ØMQ ROUTER/ROUTER coordinated by Zookeeper}
|
10
|
+
spec.homepage = "https://github.com/madvertise/zoomq"
|
11
|
+
spec.license = "MIT"
|
12
|
+
|
13
|
+
spec.files = `git ls-files`.split($/)
|
14
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
15
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
16
|
+
spec.require_paths = ["lib"]
|
17
|
+
|
18
|
+
spec.add_dependency "erubis"
|
19
|
+
spec.add_dependency "madvertise-ext"
|
20
|
+
spec.add_dependency "mixlib-cli"
|
21
|
+
spec.add_dependency "multi_json"
|
22
|
+
spec.add_dependency "ruby-protocol-buffers"
|
23
|
+
spec.add_dependency "zk"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,178 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: zoomq
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- madvertise Mobile Advertising GmbH
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-08-06 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: erubis
|
16
|
+
version_requirements: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
none: false
|
22
|
+
requirement: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
none: false
|
28
|
+
prerelease: false
|
29
|
+
type: :runtime
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: madvertise-ext
|
32
|
+
version_requirements: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - '>='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
none: false
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
none: false
|
44
|
+
prerelease: false
|
45
|
+
type: :runtime
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: mixlib-cli
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
none: false
|
54
|
+
requirement: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
none: false
|
60
|
+
prerelease: false
|
61
|
+
type: :runtime
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: multi_json
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
none: false
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
none: false
|
76
|
+
prerelease: false
|
77
|
+
type: :runtime
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: ruby-protocol-buffers
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
none: false
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
none: false
|
92
|
+
prerelease: false
|
93
|
+
type: :runtime
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: zk
|
96
|
+
version_requirements: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
none: false
|
102
|
+
requirement: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - '>='
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
none: false
|
108
|
+
prerelease: false
|
109
|
+
type: :runtime
|
110
|
+
description: ØMQ ROUTER/ROUTER coordinated by Zookeeper
|
111
|
+
email:
|
112
|
+
- tech@madvertise.com
|
113
|
+
executables:
|
114
|
+
- zoomq
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- .gitignore
|
119
|
+
- Gemfile
|
120
|
+
- LICENSE.txt
|
121
|
+
- README.md
|
122
|
+
- Rakefile
|
123
|
+
- bin/zoomq
|
124
|
+
- lib/zoomq/cli.rb
|
125
|
+
- lib/zoomq/client.rb
|
126
|
+
- lib/zoomq/handler.rb
|
127
|
+
- lib/zoomq/jeromq-0.3.0-20130721.175323-20.jar
|
128
|
+
- lib/zoomq/server.rb
|
129
|
+
- lib/zoomq/server/request_handler.rb
|
130
|
+
- lib/zoomq/server/worker.rb
|
131
|
+
- lib/zoomq/zookeeper.rb
|
132
|
+
- templates/Gemfile.tt
|
133
|
+
- templates/LICENSE.txt.tt
|
134
|
+
- templates/README.md.tt
|
135
|
+
- templates/Rakefile.tt
|
136
|
+
- templates/binwrapper.tt
|
137
|
+
- templates/client.rb.tt
|
138
|
+
- templates/config.yml.tt
|
139
|
+
- templates/console.rb.tt
|
140
|
+
- templates/console.tt
|
141
|
+
- templates/gemspec.tt
|
142
|
+
- templates/gitignore.tt
|
143
|
+
- templates/ping_request.rb.tt
|
144
|
+
- templates/production.yml.tt
|
145
|
+
- templates/protocol.proto.tt
|
146
|
+
- templates/protocol.rb.tt
|
147
|
+
- templates/rspec.tt
|
148
|
+
- templates/server.rb.tt
|
149
|
+
- templates/staging.yml.tt
|
150
|
+
- templates/testing.yml.tt
|
151
|
+
- zoomq.gemspec
|
152
|
+
homepage: https://github.com/madvertise/zoomq
|
153
|
+
licenses:
|
154
|
+
- MIT
|
155
|
+
post_install_message:
|
156
|
+
rdoc_options: []
|
157
|
+
require_paths:
|
158
|
+
- lib
|
159
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
160
|
+
requirements:
|
161
|
+
- - '>='
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '0'
|
164
|
+
none: false
|
165
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - '>='
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '0'
|
170
|
+
none: false
|
171
|
+
requirements: []
|
172
|
+
rubyforge_project:
|
173
|
+
rubygems_version: 1.8.24
|
174
|
+
signing_key:
|
175
|
+
specification_version: 3
|
176
|
+
summary: ØMQ ROUTER/ROUTER coordinated by Zookeeper
|
177
|
+
test_files: []
|
178
|
+
has_rdoc:
|