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
| | # -*- encoding: binary -*-
##
# MogileFS::Client is the MogileFS client base class. Concrete clients like
# MogileFS::MogileFS and MogileFS::Admin are implemented atop this one to do
# real work.
class MogileFS::Client
##
# The backend connection for this client
attr_reader :backend
# :stopdoc:
attr_accessor :hosts if defined? $TESTING
# :startdoc
##
# Creates a new Client. See MogileFS::Backend#initialize for how to specify
# hosts. If :readonly is set to true, the client will not modify anything
# on the server.
#
# MogileFS::Client.new :hosts => ['kaa:6001', 'ziz:6001'], :readonly => true
def initialize(args)
@hosts = args[:hosts]
@readonly = args[:readonly] ? true : false
@timeout = args[:timeout]
@fail_timeout = args[:fail_timeout]
@connect_timeout = args[:connect_timeout]
reload
end
##
# Creates a new MogileFS::Backend.
def reload
@backend = MogileFS::Backend.new(:hosts => @hosts,
:timeout => @timeout,
:fail_timeout => @fail_timeout,
:connect_timeout => @connect_timeout)
end
##
# The last error reported by the backend.
def err
@backend.lasterr
end
##
# The last error message reported by the backend.
def errstr
@backend.lasterrstr
end
##
# Is this a read-only client?
def readonly?
@readonly
end
end
|