1 # -*- encoding: binary -*-
3 # To read more about \MogileFS, go to http://mogilefs.org/
5 # Client usage information is available in MogileFS::MogileFS.
8 # Standard error class for most MogileFS-specific errors
9 class Error < StandardError; end
11 # Raised when a socket remains unreadable for too long.
12 class UnreadableSocketError < Error; end
14 # Raised when a response is truncated while reading
15 # due to network/server # errors)
16 class SizeMismatchError < Error; end
18 # Raised when checksum verification fails (only while reading deprecated
19 # "bigfiles" from the deprecated mogtool(1).
20 class ChecksumMismatchError < RuntimeError; end
22 # Raised when a backend is in read-only mode
23 class ReadOnlyError < Error
29 # Raised when an upload is impossible
30 class EmptyPathError < Error; end
32 # Raised when we are given an unsupported protocol to upload to.
33 # Currently, the \MogileFS (2.XX) server only supports HTTP and
34 # this library is only capable of HTTP.
35 class UnsupportedPathError < Error; end
37 # Raised when a request (HTTP or tracker) was truncated due to a network or
38 # server error. It may be possible to retry idempotent requests from this.
39 class RequestTruncatedError < Error; end
41 # Raised when a response from a server (HTTP or tracker) is not in a format
42 # that we expected (or truncated..
43 class InvalidResponseError < Error; end
45 # Raised when all known backends have failed.
46 class UnreachableBackendError < Error; end
48 # There was an error as a result of the use of the (experimental)
49 # pipelining code to the tracker backend
50 class PipelineError < Error; end
54 # somebody could use IO::Splice from the "io_splice" RubyGem, too
55 # don't consider this a stable API, though...
59 # IO.copy_stream was buggy in Ruby 1.9.2 and earlier
60 if RUBY_VERSION >= "1.9.3"
63 require "mogilefs/copy_stream"
64 @io = MogileFS::CopyStream
68 require 'net/http/persistent'
69 NHP = Net::HTTP::Persistent.new('mogilefs')
73 def NHP.request(uri, req)
74 Net::HTTP.start(uri.host, uri.port) { |h| h.request(req) }
78 # autoload rarely-used things:
79 autoload :Mysql, 'mogilefs/mysql'
80 autoload :Pool, 'mogilefs/pool'
81 autoload :Admin, 'mogilefs/admin'
85 require 'mogilefs/util'
86 require 'mogilefs/socket'
87 require 'mogilefs/backend'
88 require 'mogilefs/http_file'
89 require 'mogilefs/http_reader'
90 require 'mogilefs/client'
91 require 'mogilefs/bigfile'
92 require 'mogilefs/mogilefs'
93 require 'mogilefs/version' # generated by ./GIT-VERSION-GEN