new_file allows optional :info hash to be populated
[ruby-mogilefs-client.git] / lib / mogilefs.rb
blobcd58c49ffc4a1ca5713cab89033b1b42bf5b5d12
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   # autoload rarely-used things:
68   autoload :Mysql, 'mogilefs/mysql'
69   autoload :Pool, 'mogilefs/pool'
70   autoload :Admin, 'mogilefs/admin'
71   # :startdoc:
72 end
74 require 'mogilefs/util'
75 require 'mogilefs/socket'
76 require 'mogilefs/backend'
77 require 'mogilefs/http_file'
78 require 'mogilefs/http_reader'
79 require 'mogilefs/client'
80 require 'mogilefs/bigfile'
81 require 'mogilefs/mogilefs'
82 require 'mogilefs/version' # generated by ./GIT-VERSION-GEN