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/tasks/publish.rb
Defined Under Namespace
Modules: Tasks
Classes: Auth, Controller, Queue
Constant Summary
collapse
- DEFAULT_PORT =
32123
- DEFAULT_ENDPOINT =
'/scheduler'
- DEFAULT_LOGGER =
::Contentful::Webhook::Listener::Support::NullLogger.new
- VERSION =
"0.4.0"
- @@config =
nil
Class Method Summary
collapse
Class Method Details
.config ⇒ Object
32
33
34
|
# File 'lib/contentful/scheduler.rb', line 32
def self.config
@@config
end
|
.config=(config) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# 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)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/contentful/scheduler.rb', line 36
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
|