new_file: don't pass private field to create_open
[ruby-mogilefs-client.git] / lib / mogilefs.rb
blobdd60e916515f526a5cc1ec4cd5578b31a41c53bc
1 # -*- encoding: binary -*-
3 # To read more about \MogileFS, go to http://mogilefs.org/
5 # Client usage information is available in MogileFS::MogileFS.
6 module 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
24     def message # :nodoc:
25       'readonly mogilefs'
26     end
27   end
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
52   # :stopdoc:
53   class << self
54     # somebody could use IO::Splice from the "io_splice" RubyGem, too
55     # don't consider this a stable API, though...
56     attr_accessor :io
57   end
59   # IO.copy_stream was buggy in Ruby 1.9.2 and earlier
60   if RUBY_VERSION >= "1.9.3"
61     @io = IO
62   else
63     require "mogilefs/copy_stream"
64     @io = MogileFS::CopyStream
65   end
67   begin
68     require 'net/http/persistent'
69     NHP = Net::HTTP::Persistent
70   rescue LoadError
71     require 'mogilefs/nhp_fake'
72     NHP = MogileFS::NhpFake
73   end
75   # autoload rarely-used things:
76   autoload :Mysql, 'mogilefs/mysql'
77   autoload :Pool, 'mogilefs/pool'
78   autoload :Admin, 'mogilefs/admin'
79   # :startdoc:
80 end
82 require 'mogilefs/util'
83 require 'mogilefs/socket'
84 require 'mogilefs/backend'
85 require 'mogilefs/http_file'
86 require 'mogilefs/http_reader'
87 require 'mogilefs/client'
88 require 'mogilefs/bigfile'
89 require 'mogilefs/mogilefs'
90 require 'mogilefs/version' # generated by ./GIT-VERSION-GEN