Class: MogileFS::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/mogilefs/client.rb

Overview

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.

Direct Known Subclasses

Admin, MogileFS

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Client

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


25
26
27
28
29
30
31
32
# File 'lib/mogilefs/client.rb', line 25

def initialize(args)
  @hosts = args[:hosts]
  @readonly = args[:readonly] ? true : false
  @timeout = args[:timeout]
  @fail_timeout = args[:fail_timeout]

  reload
end

Instance Attribute Details

#backendObject (readonly)

The backend connection for this client



12
13
14
# File 'lib/mogilefs/client.rb', line 12

def backend
  @backend
end

#hostsObject

:stopdoc:



15
16
17
# File 'lib/mogilefs/client.rb', line 15

def hosts
  @hosts
end

Instance Method Details

#errObject

The last error reported by the backend.



46
47
48
# File 'lib/mogilefs/client.rb', line 46

def err
  @backend.lasterr
end

#errstrObject

The last error message reported by the backend.



53
54
55
# File 'lib/mogilefs/client.rb', line 53

def errstr
  @backend.lasterrstr
end

#readonly?Boolean

Is this a read-only client?

Returns:

  • (Boolean)


60
61
62
# File 'lib/mogilefs/client.rb', line 60

def readonly?
  @readonly
end

#reloadObject

Creates a new MogileFS::Backend.



37
38
39
40
41
# File 'lib/mogilefs/client.rb', line 37

def reload
  @backend = MogileFS::Backend.new(:hosts => @hosts,
                                   :timeout => @timeout,
                                   :fail_timeout => @fail_timeout)
end