Module: Contentful::Scheduler
- Defined in:
- lib/contentful/scheduler.rb,
lib/contentful/scheduler/auth.rb,
lib/contentful/scheduler/queue.rb,
lib/contentful/scheduler/version.rb,
lib/contentful/scheduler/controller.rb,
lib/contentful/scheduler/taskshelper.rb,
lib/contentful/scheduler/tasks/publish.rb,
lib/contentful/scheduler/tasks/unpublish.rb
Defined Under Namespace
Modules: Tasks, Taskshelper
Classes: Auth, Controller, Queue
Constant Summary
collapse
- DEFAULT_PORT =
32123
- DEFAULT_ENDPOINT =
'/scheduler'
- DEFAULT_LOGGER =
::Contentful::Webhook::Listener::Support::NullLogger.new
- VERSION =
"1.7.4"
- @@config =
nil
Class Method Summary
collapse
Class Method Details
.config ⇒ Object
33
34
35
|
# File 'lib/contentful/scheduler.rb', line 33
def self.config
@@config
end
|
.config=(config) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/contentful/scheduler.rb', line 17
def self.config=(config)
fail ':redis configuration missing' unless config.key?(:redis)
fail ':spaces configuration missing' unless config.key?(:spaces)
config[:spaces].each do |space, data|
fail ":management_token missing for space: #{space}" unless data.key?(:management_token)
fail ":delivery_token missing for space: #{space}" unless data.key?(:delivery_token)
end
config[:port] = (ENV.key?('PORT') ? ENV['PORT'].to_i : DEFAULT_PORT) unless config.key?(:port)
config[:logger] = DEFAULT_LOGGER unless config.key?(:logger)
config[:endpoint] = DEFAULT_ENDPOINT unless config.key?(:endpoint)
::Resque.redis = config[:redis].dup
@@config ||= config
end
|
.start(config = {}) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/contentful/scheduler.rb', line 37
def self.start(config = {})
fail "Scheduler not configured" if self.config.nil? && !block_given?
if block_given?
yield(config) if block_given?
self.config = config
end
::Contentful::Webhook::Listener::Server.start do |config|
config[:port] = self.config[:port]
config[:logger] = self.config[:logger]
config[:endpoints] = [
{
endpoint: self.config[:endpoint],
controller: ::Contentful::Scheduler::Controller,
timeout: 0
}
]
end.join
end
|