misc. documentation improvements
[ruby-mogilefs-client.git] / lib / mogilefs / client.rb
blob696f31f379acaf6ce9470f96f3a0182beb67cc74
1 # -*- encoding: binary -*-
3 ##
4 # MogileFS::Client is the MogileFS client base class.  Concrete clients like
5 # MogileFS::MogileFS and MogileFS::Admin are implemented atop this one to do
6 # real work.
7 class MogileFS::Client
9   ##
10   # The backend connection for this client
12   attr_reader :backend
14   # :stopdoc:
15   attr_accessor :hosts if defined? $TESTING
16   # :startdoc
18   ##
19   # Creates a new Client.  See MogileFS::Backend#initialize for how to specify
20   # hosts.  If :readonly is set to true, the client will not modify anything
21   # on the server.
22   #
23   #   MogileFS::Client.new :hosts => ['kaa:6001', 'ziz:6001'], :readonly => true
25   def initialize(args)
26     @hosts = args[:hosts]
27     @readonly = args[:readonly] ? true : false
28     @timeout = args[:timeout]
30     reload
31   end
33   ##
34   # Creates a new MogileFS::Backend.
36   def reload
37     @backend = MogileFS::Backend.new :hosts => @hosts, :timeout => @timeout
38   end
40   ##
41   # The last error reported by the backend.
43   def err
44     @backend.lasterr
45   end
47   ##
48   # The last error message reported by the backend.
50   def errstr
51     @backend.lasterrstr
52   end
54   ##
55   # Is this a read-only client?
57   def readonly?
58     @readonly
59   end
61 end