Module: Disbatch

Extended by:
Disbatch
Included in:
Disbatch
Defined in:
lib/disbatch.rb,
lib/disbatch/error.rb

Defined Under Namespace

Modules: Plugin Classes: AlreadyRegisteredNodeError, FailedLoadPluginError, NoDatabaseError, NoNodeError, NoPluginError, NoQueueError, Node, NotRegisteredNodeError, Queue, RegisteredNodeError, Task

Constant Summary collapse

VERSION =

engine version

'rdisbatch 0.0.9'
SPEC_VERSION =

specification version

'1.9'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#mongo_dbObject

Returns the value of attribute mongo_db.



10
11
12
# File 'lib/disbatch.rb', line 10

def mongo_db
  @mongo_db
end

#mongo_hostObject

Returns the value of attribute mongo_host.



8
9
10
# File 'lib/disbatch.rb', line 8

def mongo_host
  @mongo_host
end

#mongo_optsObject

Returns the value of attribute mongo_opts.



11
12
13
# File 'lib/disbatch.rb', line 11

def mongo_opts
  @mongo_opts
end

#mongo_portObject

Returns the value of attribute mongo_port.



9
10
11
# File 'lib/disbatch.rb', line 9

def mongo_port
  @mongo_port
end

#node_idObject

Returns the value of attribute node_id.



13
14
15
# File 'lib/disbatch.rb', line 13

def node_id
  @node_id
end

Instance Method Details

#dbObject

Return and cache the MongoDB connection pool



32
33
34
35
36
37
38
39
40
# File 'lib/disbatch.rb', line 32

def db
  begin
    @db ||= Mongo::Connection.new(@mongo_host, @mongo_port).db(@mongo_db)
  rescue
    raise Disbatch::NoDatabaseError
  end

  @db
end

#nodeObject

Return and cache the local node object



43
44
45
46
47
48
49
# File 'lib/disbatch.rb', line 43

def node
  begin
    @node ||= Disbatch::Node.get(@node_id)
  rescue Disbatch::NoNodeError
    Disbatch::Node.create(@node_id)
  end
end