mogilefs-client.git  about / heads / tags
MogileFS client library for Ruby
blob abc36804a31ee42e2e3c5df20417689b097a531f 2896 bytes (raw)
$ git show HEAD:lib/mogilefs.rb	# shows this blob on the CLI

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
 
# -*- encoding: binary -*-
#
# To read more about \MogileFS, see
# https://github.com/mogilefs/MogileFS-Server/wiki
#
# Client usage information is available in MogileFS::MogileFS.
module MogileFS

  # :stopdoc:
  if defined?(Process::CLOCK_MONOTONIC)
    def self.now
      Process.clock_gettime(Process::CLOCK_MONOTONIC)
    end
  else
    def self.now
      Time.now.to_f
    end
  end
  # :startdoc:

  # Standard error class for most MogileFS-specific errors
  Error = Class.new(StandardError)

  # Raised when a socket remains unreadable for too long.
  UnreadableSocketError = Class.new(Error)

  # Raised when a response is truncated while reading
  # due to network/server # errors)
  SizeMismatchError = Class.new(Error)

  # Raised when checksum verification fails (only while reading deprecated
  # "bigfiles" from the deprecated mogtool(1).
  ChecksumMismatchError = Class.new(RuntimeError)

  # Raised when a backend is in read-only mode
  class ReadOnlyError < Error
    def message # :nodoc:
      'readonly mogilefs'
    end
  end

  # Raised when an upload is impossible
  EmptyPathError = Class.new(Error)

  # Raised when we are given an unsupported protocol to upload to.
  # Currently, the \MogileFS (2.XX) server only supports HTTP and
  # this library is only capable of HTTP.
  UnsupportedPathError = Class.new(Error)

  # Raised when a request (HTTP or tracker) was truncated due to a network or
  # server error.  It may be possible to retry idempotent requests from this.
  RequestTruncatedError = Class.new(Error)

  # Raised when a response from a server (HTTP or tracker) is not in a format
  # that we expected (or truncated..
  InvalidResponseError = Class.new(Error)

  # Raised when all known backends have failed.
  UnreachableBackendError = Class.new(Error)

  # There was an error as a result of the use of the (experimental)
  # pipelining code to the tracker backend
  PipelineError = Class.new(Error)

  # :stopdoc:
  class << self
    # somebody could use IO::Splice from the "io_splice" RubyGem, too
    # don't consider this a stable API, though...
    attr_accessor :io
  end

  # IO.copy_stream was buggy in Ruby 1.9.2 and earlier
  if RUBY_VERSION >= "1.9.3"
    @io = IO
  else
    require "mogilefs/copy_stream"
    @io = MogileFS::CopyStream
  end

  begin
    require 'net/http/persistent'
    NHP = Net::HTTP::Persistent
  rescue LoadError
    require 'mogilefs/nhp_fake'
    NHP = MogileFS::NhpFake
  end

  # autoload rarely-used things:
  autoload :Mysql, 'mogilefs/mysql'
  autoload :Pool, 'mogilefs/pool'
  autoload :Admin, 'mogilefs/admin'
  # :startdoc:
end

require 'mogilefs/util'
require 'mogilefs/socket'
require 'mogilefs/backend'
require 'mogilefs/http_file'
require 'mogilefs/http_reader'
require 'mogilefs/client'
require 'mogilefs/bigfile'
require 'mogilefs/mogilefs'
require 'mogilefs/version' # generated by ./GIT-VERSION-GEN

git clone https://yhbt.net/mogilefs-client.git