Class: RocketJob::Config

Inherits:
Object
  • Object
show all
Includes:
MongoMapper::Document, SyncAttr
Defined in:
lib/rocket_job/config.rb

Overview

Centralized Configuration for Rocket Jobs

Class Method Summary collapse

Class Method Details

.mongo_connection=(connection) ⇒ Object

Replace the MongoMapper default mongo connection for holding jobs



52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/rocket_job/config.rb', line 52

def self.mongo_connection=(connection)
  connection(connection)
  Worker.connection(connection)
  Job.connection(connection)
  Config.connection(connection)
  DirmonEntry.connection(connection)

  db_name = connection.db.name
  set_database_name(db_name)
  Worker.set_database_name(db_name)
  Job.set_database_name(db_name)
  Config.set_database_name(db_name)
  DirmonEntry.set_database_name(db_name)
end

.mongo_work_connectionObject

Returns the Mongo connection for the Records and Results



81
82
83
# File 'lib/rocket_job/config.rb', line 81

def self.mongo_work_connection
  @@mongo_work_connection || connection
end

.mongo_work_connection=(connection) ⇒ Object

Use a separate Mongo connection for the Records and Results Allows the records and results to be stored in a separate Mongo database from the Jobs themselves.

It is recommended to set the work_connection to a local Mongo Worker that is not replicated to another data center to prevent flooding the network with replication of data records and results. The jobs themselves can/should be replicated across data centers so that they are never lost.



76
77
78
# File 'lib/rocket_job/config.rb', line 76

def self.mongo_work_connection=(connection)
  @@mongo_work_connection = connection
end