* [PATCH] support net-http-persistent 3.x
@ 2017-01-26 22:14 6% Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2017-01-26 22:14 UTC (permalink / raw)
To: mogilefs-client-public
The optional net-http-persistent RubyGem we use has a major
incompatible change from the 2.x versions. Support them both.
---
examples/stale_fid_checker.rb | 4 +++-
lib/mogilefs/mogilefs.rb | 11 +++++++++--
test/test_nhp_compat.rb | 25 +++++++++++++++++++++++++
3 files changed, 37 insertions(+), 3 deletions(-)
create mode 100644 test/test_nhp_compat.rb
diff --git a/examples/stale_fid_checker.rb b/examples/stale_fid_checker.rb
index 2dab866..769ffda 100644
--- a/examples/stale_fid_checker.rb
+++ b/examples/stale_fid_checker.rb
@@ -34,7 +34,9 @@
end
adm = MogileFS::Admin.new(:hosts => trackers)
-NHP = Net::HTTP::Persistent.new(File.basename($0))
+name = File.basename($0)
+Net::HTTP::Persistent::VERSION >= 3.0 and name = { :name => name }
+NHP = Net::HTTP::Persistent.new(name)
client = MogileFS::MogileFS.new(:hosts => trackers, :domain => "none")
def start_perdev_thread(pfx)
diff --git a/lib/mogilefs/mogilefs.rb b/lib/mogilefs/mogilefs.rb
index d17f0b8..724dfb6 100644
--- a/lib/mogilefs/mogilefs.rb
+++ b/lib/mogilefs/mogilefs.rb
@@ -73,9 +73,9 @@ def initialize(args = {})
@get_file_data_timeout = args[:get_file_data_timeout] || 5
@new_file_max_time = args[:new_file_max_time] || 3600.0
- @nhp_get = MogileFS::NHP.new('get')
+ @nhp_get = nhp_new('get')
@nhp_get.open_timeout = @nhp_get.read_timeout = @get_file_data_timeout
- @nhp_put = MogileFS::NHP.new('put')
+ @nhp_put = nhp_new('put')
@nhp_put.open_timeout = @nhp_put.read_timeout = @new_file_max_time
raise ArgumentError, "you must specify a domain" unless @domain
@@ -548,4 +548,11 @@ def file_debug(args)
end
end
end
+
+ def nhp_new(name) # :nodoc:
+ Net::HTTP::Persistent::VERSION.to_f >= 3.0 and name = { :name => name }
+ MogileFS::NHP.new(name)
+ rescue NameError
+ MogileFS::NHP.new(name)
+ end
end
diff --git a/test/test_nhp_compat.rb b/test/test_nhp_compat.rb
new file mode 100644
index 0000000..282dcf5
--- /dev/null
+++ b/test/test_nhp_compat.rb
@@ -0,0 +1,25 @@
+require 'test/unit'
+
+class TestNhpCompat < Test::Unit::TestCase
+
+ def test_nhp_compat
+ ver_test_nhp('~> 2.9')
+ ver_test_nhp('~> 3.0')
+ end
+
+ def ver_test_nhp(verspec)
+ pid = fork do
+ begin
+ gem 'net-http-persistent', verspec
+ rescue LoadError => e
+ warn "SKIPPING net-http-persistent #{verspec}\n" \
+ "#{e.message} (#{e.class})\n"
+ end
+ require 'mogilefs'
+ mg = MogileFS::MogileFS.new :hosts => %w(127.0.0.1:7500), :domain => 'x'
+ exit!(Net::HTTP::Persistent === mg.nhp_new('foo'))
+ end
+ _, status = Process.waitpid2(pid)
+ assert status.success?, status.inspect
+ end
+end
--
EW
^ permalink raw reply related [relevance 6%]
* [ANN] mogilefs-client 3.11.0 - MogileFS client library for Ruby
@ 2017-01-31 18:38 7% Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2017-01-31 18:38 UTC (permalink / raw)
To: ruby-talk, mogile; +Cc: mogilefs-client-public
A MogileFS client library for Ruby. MogileFS is an open source
distributed filesystem, see: http://mogilefs.org/ for more details.
This library allows any Ruby application to read, write and delete
files in a MogileFS instance.
Changes:
This release provides compatibility with net-http-persistent 3.x
while retaining support for the (API-incompatible) 2.x series.
Users of mainline Ruby 2.2+ get a workaround for excessive
garbage for uploading files. This excessive garbage on IO#write
should be fixed when Ruby 2.5 gets released on Dec 25, 2017:
https://bugs.ruby-lang.org/issues/13085
There's also a few minor garbage reductions of small strings,
relying on the maintained cmogstored for Content-Range PUT
testing, and some minor build system and documentation updates.
12 changes since 3.10.0 (Aug 2016):
avoid pointless capture in regexp
use opt_str_freeze to avoid allocations in a few places
new_file/common: simplify empty class declarations
support net-http-persistent 3.x
test: switch to cmogstored for testing Content-Range PUTs
avoid excessive garbage on uploads with Ruby 2.2+
socket_common: limit IO#write garbage workaround to <= 2.4
freeze string literals in a few more places
update URLS to HTTPS
README: explain removal of NFS support
doc: remove private email address linkage
gemspec: remove olddoc development dependency
rdoc :: https://bogomips.org/mogilefs-client/
feed :: https://bogomips.org/mogilefs-client/NEWS.atom.xml
list :: mogilefs-client-public@bogomips.org
list-cc :: mogile@googlegroups.com
list-archive :: https://bogomips.org/mogilefs-client-public/
git clone git://bogomips.org/mogilefs-client.git
nntp://news.public-inbox.org/inbox.comp.file-systems.mogilefs.ruby
^ permalink raw reply [relevance 7%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2017-01-26 22:14 6% [PATCH] support net-http-persistent 3.x Eric Wong
2017-01-31 18:38 7% [ANN] mogilefs-client 3.11.0 - MogileFS client library for Ruby Eric Wong
Code repositories for project(s) associated with this public inbox
https://yhbt.net/mogilefs-client.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).