backend: more descriptive error for backends being unreachable
[ruby-mogilefs-client.git] / lib / mogilefs.rb
blob506d64b4c166ef340bdcce6818c693c105025acf
1 # -*- encoding: binary -*-
2 ##
3 # MogileFS is a Ruby client for Danga Interactive's open source distributed
4 # filesystem.
6 # To read more about Danga's MogileFS: http://danga.com/mogilefs/
8 module MogileFS
10   VERSION = '2.2.0'
12   ##
13   # Raised when a socket remains unreadable for too long.
15   class Error < StandardError; end
16   class UnreadableSocketError < Error; end
17   class SizeMismatchError < Error; end
18   class ChecksumMismatchError < RuntimeError; end
19   class ReadOnlyError < Error
20     def message; 'readonly mogilefs'; end
21   end
22   class EmptyPathError < Error; end
23   class UnsupportedPathError < Error; end
24   class RequestTruncatedError < Error; end
25   class InvalidResponseError < Error; end
26   class UnreachableBackendError < Error; end
28   # IO.copy_stream was buggy in Ruby 1.9.2 and earlier
29   if RUBY_VERSION >= "1.9.3"
30     X = IO
31   else
32     require "mogilefs/copy_stream"
33     X = MogileFS::CopyStream
34   end
36   # autoload rarely-used things:
37   autoload :Mysql, 'mogilefs/mysql'
38   autoload :Pool, 'mogilefs/pool'
39   autoload :Admin, 'mogilefs/admin'
40 end
42 require 'mogilefs/util'
43 require 'mogilefs/socket'
44 require 'mogilefs/backend'
45 require 'mogilefs/http_file'
46 require 'mogilefs/http_reader'
47 require 'mogilefs/client'
48 require 'mogilefs/bigfile'
49 require 'mogilefs/mogilefs'