Module: Chronos
- Defined in:
- lib/chronos.rb,
lib/chronos/version.rb
Overview
The top-level module for this gem. It’s purpose is to hold global configuration variables that are used as defaults in other classes.
Defined Under Namespace
Modules: Error Classes: Connection
Constant Summary collapse
- DEFAULT_URL =
'http://localhost:4400'- VERSION =
'0.0.1'
Class Method Summary collapse
-
.add(job) ⇒ Object
add job.
-
.connection ⇒ Object
Set a new connection.
-
.delete(name) ⇒ Object
delete job.
-
.delete_all ⇒ Object
delete all jobs.
-
.env_options ⇒ Object
Get marathon options from environment.
-
.env_url ⇒ Object
Get the chronos url from environment.
-
.list ⇒ Object
list jobs.
-
.logger ⇒ Object
Returns the value of attribute logger.
-
.logger=(value) ⇒ Object
Sets the attribute logger.
-
.options ⇒ Object
Get options for connecting to marathon API.
-
.options=(new_options) ⇒ Object
Set new options.
-
.reset_connection! ⇒ Object
Reset the connection.
-
.start(name) ⇒ Object
start a job.
-
.url ⇒ Object
Get the marathon API URL.
-
.url=(new_url) ⇒ Object
Set a new url.
Class Method Details
.add(job) ⇒ Object
add job
72 73 74 |
# File 'lib/chronos.rb', line 72 def add(job) connection.post('/scheduler/iso8601', nil, body: job) end |
.connection ⇒ Object
Set a new connection
57 58 59 |
# File 'lib/chronos.rb', line 57 def connection @connection ||= Connection.new(url, ) end |
.delete(name) ⇒ Object
delete job
77 78 79 |
# File 'lib/chronos.rb', line 77 def delete(name) connection.delete("/scheduler/job/#{URI.encode name}") end |
.delete_all ⇒ Object
delete all jobs
82 83 84 |
# File 'lib/chronos.rb', line 82 def delete_all connection.delete('/scheduler/jobs') end |
.env_options ⇒ Object
Get marathon options from environment
26 27 28 29 30 31 |
# File 'lib/chronos.rb', line 26 def opts = {} opts[:username] = ENV['CHRONOS_USER'] if ENV['CHRONOS_USER'] opts[:password] = ENV['CHRONOS_PASSWORD'] if ENV['CHRONOS_PASSWORD'] opts end |
.env_url ⇒ Object
Get the chronos url from environment
21 22 23 |
# File 'lib/chronos.rb', line 21 def env_url ENV['CHRONOS_URL'] end |
.list ⇒ Object
list jobs
67 68 69 |
# File 'lib/chronos.rb', line 67 def list connection.get('/scheduler/jobs') end |
.logger ⇒ Object
Returns the value of attribute logger.
12 13 14 |
# File 'lib/chronos.rb', line 12 def logger @logger end |
.logger=(value) ⇒ Object
Sets the attribute logger
12 13 14 |
# File 'lib/chronos.rb', line 12 def logger=(value) @logger = value end |
.options ⇒ Object
Get options for connecting to marathon API
40 41 42 |
# File 'lib/chronos.rb', line 40 def @options ||= end |
.options=(new_options) ⇒ Object
Set new options
51 52 53 54 |
# File 'lib/chronos.rb', line 51 def () @options = .merge( || {}) reset_connection! end |
.reset_connection! ⇒ Object
Reset the connection
62 63 64 |
# File 'lib/chronos.rb', line 62 def reset_connection! @connection = nil end |
.start(name) ⇒ Object
start a job
87 88 89 |
# File 'lib/chronos.rb', line 87 def start(name) connection.put("/scheduler/job/#{URI.encode name}") end |
.url ⇒ Object
Get the marathon API URL
34 35 36 37 |
# File 'lib/chronos.rb', line 34 def url @url ||= env_url || DEFAULT_URL @url end |
.url=(new_url) ⇒ Object
Set a new url
45 46 47 48 |
# File 'lib/chronos.rb', line 45 def url=(new_url) @url = new_url reset_connection! end |