Module: Magent
- Defined in:
- lib/magent/async.rb,
lib/magent.rb,
lib/magent/stats.rb,
lib/magent/utils.rb,
lib/magent/failure.rb,
lib/magent/railtie.rb,
lib/magent/processor.rb,
lib/magent/async_channel.rb,
lib/magent/generic_channel.rb
Overview
Example
class Processor
include Magent::Async
[..snip..]
def process
puts "Processing #{@params}"
end
end
async call:
Processor.find(id).async(:my_queue, priority).process
chained methods:
Processor.async(:my_queue, priority).find(1).process
Defined Under Namespace
Modules: Async, Failure, Stats, Utils
Classes: AsyncChannel, GenericChannel, Processor, Railtie
Constant Summary
collapse
- @@database_name =
"magent"
- @@config =
{
"host" => "0.0.0.0",
"port" => 27017
}
Class Method Summary
collapse
Class Method Details
.auth(username, passwd) ⇒ Object
98
99
100
101
|
# File 'lib/magent.rb', line 98
def self.auth(username, passwd)
@@config['username'] = username
@@config['password'] = passwd
end
|
.config ⇒ Object
55
56
57
|
# File 'lib/magent.rb', line 55
def self.config
@@config
end
|
.config=(config) ⇒ Object
59
60
61
|
# File 'lib/magent.rb', line 59
def self.config=(config)
@@config = config
end
|
.connect(environment, options = {}) ⇒ Object
71
72
73
74
75
76
77
78
|
# File 'lib/magent.rb', line 71
def self.connect(environment, options={})
raise 'Set config before connecting. Magent.config = {...}' if config.nil? || config.empty?
env = config_for_environment(environment)
Magent.connection = Mongo::Connection.new(env['host'], env['port'], options)
Magent.database = env['database']
Magent.database.authenticate(env['username'], env['password']) if env['username'] && env['password']
end
|
.connection ⇒ Object
34
35
36
|
# File 'lib/magent.rb', line 34
def self.connection
@@connection ||= Mongo::Connection.new
end
|
.connection=(new_connection) ⇒ Object
42
43
44
|
# File 'lib/magent.rb', line 42
def self.connection=(new_connection)
@@connection = new_connection
end
|
.database ⇒ Object
51
52
53
|
# File 'lib/magent.rb', line 51
def self.database
@@database ||= Magent.connection.db(@@database_name)
end
|
.database=(name) ⇒ Object
46
47
48
49
|
# File 'lib/magent.rb', line 46
def self.database=(name)
@@database = nil
@@database_name = name
end
|
.db_name=(db_name) ⇒ Object
94
95
96
|
# File 'lib/magent.rb', line 94
def self.db_name=(db_name)
@@database_name = db_name
end
|
.host=(host) ⇒ Object
86
87
88
|
# File 'lib/magent.rb', line 86
def self.host=(host)
@@config['host'] = host
end
|
.logger ⇒ Object
38
39
40
|
# File 'lib/magent.rb', line 38
def self.logger
connection.logger
end
|
.port=(port) ⇒ Object
90
91
92
|
# File 'lib/magent.rb', line 90
def self.port=(port)
@@config['port'] = port
end
|
.setup(config, environment = nil, options = {}) ⇒ Object
80
81
82
83
|
# File 'lib/magent.rb', line 80
def self.setup(config, environment = nil, options = {})
self.config = config
connect(environment, options)
end
|
.sync_mode ⇒ Object
63
64
65
|
# File 'lib/magent.rb', line 63
def self.sync_mode
@@sync_mode ||= false
end
|
.sync_mode=(m) ⇒ Object
67
68
69
|
# File 'lib/magent.rb', line 67
def self.sync_mode=(m)
@@sync_mode = m
end
|