Class: Proxy::RemoteExecution::Ssh::JobStorage
- Inherits:
-
Object
- Object
- Proxy::RemoteExecution::Ssh::JobStorage
- Defined in:
- lib/smart_proxy_remote_execution_ssh/job_storage.rb
Instance Method Summary collapse
- #drop_job(execution_plan_uuid, run_step_id) ⇒ Object
- #find_job(uuid, hostname) ⇒ Object
-
#initialize ⇒ JobStorage
constructor
A new instance of JobStorage.
- #job_uuids_for_host(hostname) ⇒ Object
- #store_job(hostname, execution_plan_uuid, run_step_id, job, uuid: SecureRandom.uuid, timestamp: Time.now.utc, effective_user: nil) ⇒ Object
Constructor Details
#initialize ⇒ JobStorage
Returns a new instance of JobStorage.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/smart_proxy_remote_execution_ssh/job_storage.rb', line 6 def initialize @db = Sequel.sqlite @db.create_table :jobs do DateTime :timestamp, null: false, default: Sequel::CURRENT_TIMESTAMP String :uuid, fixed: true, size: 36, primary_key: true, null: false String :hostname, null: false, index: true String :execution_plan_uuid, fixed: true, size: 36, null: false, index: true Integer :run_step_id, null: false String :effective_user String :job, text: true end end |
Instance Method Details
#drop_job(execution_plan_uuid, run_step_id) ⇒ Object
39 40 41 |
# File 'lib/smart_proxy_remote_execution_ssh/job_storage.rb', line 39 def drop_job(execution_plan_uuid, run_step_id) jobs.where(execution_plan_uuid: execution_plan_uuid, run_step_id: run_step_id).delete end |
#find_job(uuid, hostname) ⇒ Object
19 20 21 |
# File 'lib/smart_proxy_remote_execution_ssh/job_storage.rb', line 19 def find_job(uuid, hostname) jobs.where(uuid: uuid, hostname: hostname).first end |
#job_uuids_for_host(hostname) ⇒ Object
23 24 25 26 |
# File 'lib/smart_proxy_remote_execution_ssh/job_storage.rb', line 23 def job_uuids_for_host(hostname) jobs_for_host(hostname).order(:timestamp) .select_map(:uuid) end |
#store_job(hostname, execution_plan_uuid, run_step_id, job, uuid: SecureRandom.uuid, timestamp: Time.now.utc, effective_user: nil) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/smart_proxy_remote_execution_ssh/job_storage.rb', line 28 def store_job(hostname, execution_plan_uuid, run_step_id, job, uuid: SecureRandom.uuid, timestamp: Time.now.utc, effective_user: nil) jobs.insert(timestamp: , uuid: uuid, hostname: hostname, execution_plan_uuid: execution_plan_uuid, run_step_id: run_step_id, job: job, effective_user: effective_user) uuid end |