hermann 0.18.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +45 -0
- data/ext/hermann/extconf.rb +149 -0
- data/ext/hermann/hermann_lib.c +1041 -0
- data/ext/hermann/hermann_lib.h +107 -0
- data/ext/patches/librdkafka/0006-Update-some-headers-to-include-the-right-headers-to-.patch +57 -0
- data/lib/hermann/consumer.rb +24 -0
- data/lib/hermann/discovery/zookeeper.rb +85 -0
- data/lib/hermann/errors.rb +14 -0
- data/lib/hermann/producer.rb +150 -0
- data/lib/hermann/provider/java_producer.rb +106 -0
- data/lib/hermann/result.rb +74 -0
- data/lib/hermann/timeout.rb +37 -0
- data/lib/hermann/version.rb +3 -0
- data/lib/hermann.rb +20 -0
- data/lib/hermann_jars.rb +15 -0
- metadata +137 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6da9dc68c659381482844060d7534fb070fde17e
|
4
|
+
data.tar.gz: 74ea4247774c4cabe6880b1db45a0234b9a8ab83
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c32c2668dcb9ccfc6f6768e3cdef001c450f29ae45887b262ca5b43bccd1f3817658bee048889b1a5af5ace3ce6761c06da79903f93394d8fa3e30beeb160da8
|
7
|
+
data.tar.gz: a164452507a36f750f8e480806fc5713b715b070e26c73bfa25c3931f7944f09c736fcc48e271615f138a248d9469b3b131993340dafb54fc8e2793b03512988
|
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'fileutils'
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'rake/extensiontask'
|
6
|
+
|
7
|
+
|
8
|
+
Rake::ExtensionTask.new do |t|
|
9
|
+
t.name = 'hermann_lib'
|
10
|
+
t.ext_dir = 'ext/hermann'
|
11
|
+
t.gem_spec = Gem::Specification.load('hermann.gemspec')
|
12
|
+
end
|
13
|
+
|
14
|
+
RSpec::Core::RakeTask.new(:spec) do |r|
|
15
|
+
options = ['--tag ~type:integration']
|
16
|
+
|
17
|
+
if RUBY_PLATFORM == 'java'
|
18
|
+
options << '--tag ~platform:mri'
|
19
|
+
else
|
20
|
+
options << '--tag ~platform:java'
|
21
|
+
end
|
22
|
+
|
23
|
+
r.rspec_opts = options.join(' ')
|
24
|
+
end
|
25
|
+
|
26
|
+
namespace :spec do
|
27
|
+
RSpec::Core::RakeTask.new(:integration) do |r|
|
28
|
+
r.rspec_opts = '--tag type:integration'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'Remove the entire ./tmp directory'
|
33
|
+
task :removetmp do
|
34
|
+
FileUtils.rm_rf('tmp')
|
35
|
+
end
|
36
|
+
|
37
|
+
task :clean => [:removetmp]
|
38
|
+
|
39
|
+
if RUBY_PLATFORM == 'java'
|
40
|
+
task :default => [:clean, :spec]
|
41
|
+
else
|
42
|
+
task :build => [:compile]
|
43
|
+
task :default => [:clean, :build, :spec]
|
44
|
+
end
|
45
|
+
|
@@ -0,0 +1,149 @@
|
|
1
|
+
# External configuration for Hermann Gem
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'mkmf'
|
5
|
+
require 'mini_portile'
|
6
|
+
require 'digest/md5'
|
7
|
+
|
8
|
+
RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
|
9
|
+
|
10
|
+
LIBDIR = RbConfig::CONFIG['libdir']
|
11
|
+
INCLUDEDIR = RbConfig::CONFIG['includedir']
|
12
|
+
BASE_DIR = File.expand_path(File.dirname(__FILE__) + '/../../')
|
13
|
+
|
14
|
+
puts "Library Dir: #{LIBDIR}\n"
|
15
|
+
puts "Include Dir: #{INCLUDEDIR}"
|
16
|
+
|
17
|
+
################################################################################
|
18
|
+
# MiniPortile overrides
|
19
|
+
################################################################################
|
20
|
+
# RdKafkaRecipe is a class that adds some librdkafka specific customizations to
|
21
|
+
# make sure that we can safely build librdkafka when installing this gem
|
22
|
+
class RdKafkaRecipe < MiniPortile
|
23
|
+
attr_accessor :checksum
|
24
|
+
|
25
|
+
def configure
|
26
|
+
execute('configure', %Q(bash configure #{computed_options}))
|
27
|
+
end
|
28
|
+
|
29
|
+
def configured?
|
30
|
+
File.exists?(File.join(work_path, 'Makefile.config'))
|
31
|
+
end
|
32
|
+
|
33
|
+
# Overriding this from MiniPortile because it includes autoconf defaults that
|
34
|
+
# don't apply to librdkafka's mklove-based configure script
|
35
|
+
def configure_defaults
|
36
|
+
[]
|
37
|
+
end
|
38
|
+
|
39
|
+
def download_file(url, full_path, count=3)
|
40
|
+
super(url, full_path, count)
|
41
|
+
|
42
|
+
# Support some simple checksumming
|
43
|
+
unless Digest::MD5.hexdigest(File.read(full_path)) == checksum
|
44
|
+
raise 'Checksum error!'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def download_file_http(url, full_path, count = 3)
|
49
|
+
filename = File.basename(full_path)
|
50
|
+
uri = URI.parse(url)
|
51
|
+
|
52
|
+
if ENV['http_proxy']
|
53
|
+
_, userinfo, p_host, p_port = URI.split(ENV['http_proxy'])
|
54
|
+
proxy_user, proxy_pass = userinfo.split(/:/) if userinfo
|
55
|
+
http = Net::HTTP.new(uri.host, uri.port, p_host, p_port, proxy_user, proxy_pass)
|
56
|
+
else
|
57
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
58
|
+
|
59
|
+
if URI::HTTPS === uri
|
60
|
+
http.use_ssl = true
|
61
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
62
|
+
|
63
|
+
store = OpenSSL::X509::Store.new
|
64
|
+
|
65
|
+
# Auto-include system-provided certificates
|
66
|
+
store.set_default_paths
|
67
|
+
|
68
|
+
if ENV.has_key?("SSL_CERT_FILE") && File.exist?(ENV["SSL_CERT_FILE"])
|
69
|
+
store.add_file ENV["SSL_CERT_FILE"]
|
70
|
+
end
|
71
|
+
|
72
|
+
http.cert_store = store
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
message "Downloading #{filename} "
|
77
|
+
http.start do |h|
|
78
|
+
h.request_get(uri.path, 'Accept-Encoding' => 'identity') do |response|
|
79
|
+
case response
|
80
|
+
when Net::HTTPNotFound
|
81
|
+
output "404 - Not Found"
|
82
|
+
return false
|
83
|
+
|
84
|
+
when Net::HTTPClientError
|
85
|
+
output "Error: Client Error: #{response.inspect}"
|
86
|
+
return false
|
87
|
+
|
88
|
+
when Net::HTTPRedirection
|
89
|
+
raise "Too many redirections for the original URL, halting." if count <= 0
|
90
|
+
url = response["location"]
|
91
|
+
return download_file(url, full_path, count - 1)
|
92
|
+
|
93
|
+
when Net::HTTPOK
|
94
|
+
return with_tempfile(filename, full_path) do |temp_file|
|
95
|
+
size = 0
|
96
|
+
progress = 0
|
97
|
+
total = response.header["Content-Length"].to_i
|
98
|
+
|
99
|
+
if total == 0
|
100
|
+
# There are cases when apparently GitHub.com will return an empty
|
101
|
+
# content-length header, which means we can't really trust the
|
102
|
+
# response, so we'll treat it like a redirect
|
103
|
+
puts "Empty content-length header, retrying"
|
104
|
+
return download_file(url, full_path, count - 1)
|
105
|
+
end
|
106
|
+
|
107
|
+
response.read_body do |chunk|
|
108
|
+
temp_file << chunk
|
109
|
+
size += chunk.size
|
110
|
+
new_progress = (size * 100) / total
|
111
|
+
unless new_progress == progress
|
112
|
+
message "\rDownloading %s (%3d%%) " % [filename, new_progress]
|
113
|
+
end
|
114
|
+
progress = new_progress
|
115
|
+
end
|
116
|
+
output
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
################################################################################
|
124
|
+
|
125
|
+
librdkafka = RdKafkaRecipe.new('librdkafka', '0.8.4')
|
126
|
+
librdkafka.files = ["https://github.com/edenhill/librdkafka/archive/#{librdkafka.version}.tar.gz"]
|
127
|
+
librdkafka.checksum = '28a3252fd0f31d4a38bea9cd25083a06'
|
128
|
+
librdkafka.patch_files = Dir["#{File.join(BASE_DIR, 'ext', 'patches', 'librdkafka')}/*.patch"]
|
129
|
+
checkpoint = ".librdkafka.#{librdkafka.version}.cooked"
|
130
|
+
|
131
|
+
unless File.exists?(checkpoint)
|
132
|
+
librdkafka.cook
|
133
|
+
File.open(checkpoint, 'w+') do |f|
|
134
|
+
f.write("Cooked: #{Time.now}\n")
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
librdkafka.activate
|
139
|
+
|
140
|
+
HEADER_DIRS = [INCLUDEDIR, File.join(librdkafka.path, 'include')]
|
141
|
+
LIB_DIRS = [LIBDIR]
|
142
|
+
dir_config('rdkafka', HEADER_DIRS, LIB_DIRS)
|
143
|
+
|
144
|
+
# Tell mkmf to staticallly link our mini_portile generated static library,
|
145
|
+
# courtesty of:
|
146
|
+
# <http://blog.zachallett.com/howto-ruby-c-extension-with-a-static-library>
|
147
|
+
$LOCAL_LIBS << File.join(librdkafka.path, 'lib', 'librdkafka.a')
|
148
|
+
|
149
|
+
create_makefile('hermann/hermann_lib')
|