Module: Postqueue
- Extended by:
- DefaultQueue, SingleForwardable
- Defined in:
- lib/postqueue.rb,
lib/postqueue/cli.rb,
lib/postqueue/item.rb,
lib/postqueue/queue.rb,
lib/postqueue/logger.rb,
lib/postqueue/version.rb,
lib/postqueue/cli/stats.rb,
lib/postqueue/item/enqueue.rb,
lib/postqueue/queue/runner.rb,
lib/postqueue/queue/timing.rb,
lib/postqueue/default_queue.rb,
lib/postqueue/item/inserter.rb,
lib/postqueue/queue/logging.rb,
lib/postqueue/queue/callback.rb,
lib/postqueue/queue/processing.rb,
lib/postqueue/cli/options_parser.rb,
lib/postqueue/queue/select_and_lock.rb
Defined Under Namespace
Modules: CLI, DefaultQueue
Classes: Item, MissingHandler, Queue, Timing
Constant Summary
collapse
- VERSION =
"0.6.0"
Class Method Summary
collapse
default_queue
Class Method Details
.default_logger ⇒ Object
10
11
12
|
# File 'lib/postqueue/logger.rb', line 10
def self.default_logger
defined?(Rails) ? Rails.logger : stdout_logger
end
|
.logger ⇒ Object
6
7
8
|
# File 'lib/postqueue/logger.rb', line 6
def self.logger
@logger || default_logger
end
|
.logger=(logger) ⇒ Object
2
3
4
|
# File 'lib/postqueue/logger.rb', line 2
def self.logger=(logger)
@logger ||= logger
end
|
.migrate!(table_name = "postqueue") ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/postqueue/item.rb', line 25
def self.migrate!(table_name = "postqueue")
Item.connection.execute <<-SQL
CREATE TABLE #{table_name} (
id SERIAL PRIMARY KEY,
op VARCHAR,
entity_id INTEGER NOT NULL DEFAULT 0,
created_at timestamp without time zone NOT NULL DEFAULT (now() at time zone 'utc'),
next_run_at timestamp without time zone NOT NULL DEFAULT (now() at time zone 'utc'),
failed_attempts INTEGER NOT NULL DEFAULT 0
);
-- This index should be usable to find duplicate duplicates in the table. While
-- we search for entries with matching op and entity_id, we assume that entity_id
-- has a much higher cardinality.
CREATE INDEX #{table_name}_idx1 ON #{table_name}(entity_id);
-- This index should help picking the next entries to run. Otherwise a full tablescan
-- would be necessary whenevr we check out items.
CREATE INDEX #{table_name}_idx2 ON #{table_name}(next_run_at);
SQL
end
|
.new(*args, &block) ⇒ Object
9
10
11
|
# File 'lib/postqueue.rb', line 9
def new(*args, &block)
::Postqueue::Queue.new(*args, &block)
end
|
.stdout_logger ⇒ Object
14
15
16
|
# File 'lib/postqueue/logger.rb', line 14
def self.stdout_logger
@stdout_logger ||= Logger.new(STDOUT)
end
|
.unmigrate!(table_name = "postqueue") ⇒ Object
19
20
21
22
23
|
# File 'lib/postqueue/item.rb', line 19
def self.unmigrate!(table_name = "postqueue")
Item.connection.execute <<-SQL
DROP TABLE IF EXISTS #{table_name};
SQL
end
|