Class: Cyclid::API::Plugins::Notifier::Local

Inherits:
Base
  • Object
show all
Defined in:
app/cyclid/plugins/dispatcher/local.rb

Overview

This is a local Notifier, so it can just pass updates directly on to the JobRecord & LogBuffer

Instance Method Summary collapse

Constructor Details

#initialize(job_id, callback) ⇒ Local

Returns a new instance of Local.



98
99
100
101
102
103
104
105
106
# File 'app/cyclid/plugins/dispatcher/local.rb', line 98

def initialize(job_id, callback)
  @job_id = job_id
  @job_record = JobRecord.find(job_id)

  # Create a LogBuffer
  @log_buffer = LogBuffer.new(@job_record)

  @callback = callback
end

Instance Method Details

#completion(success) ⇒ Object

Ping the callback completion hook, if required



124
125
126
# File 'app/cyclid/plugins/dispatcher/local.rb', line 124

def completion(success)
  @callback&.completion(@job_id, success)
end

#ended=(time) ⇒ Object

Set the JobRecord ended



118
119
120
121
# File 'app/cyclid/plugins/dispatcher/local.rb', line 118

def ended=(time)
  @job_record.ended = time
  @job_record.save!
end

#status=(status) ⇒ Object

Set the JobRecord status



109
110
111
112
113
114
115
# File 'app/cyclid/plugins/dispatcher/local.rb', line 109

def status=(status)
  @job_record.status = status
  @job_record.save!

  # Ping the callback status_changed hook, if required
  @callback&.status_changed(@job_id, status)
end

#write(data) ⇒ Object

Write data to the log buffer



129
130
131
132
133
134
# File 'app/cyclid/plugins/dispatcher/local.rb', line 129

def write(data)
  @log_buffer.write data

  # Ping the callback log_write hook, if required
  @callback&.log_write(@job_id, data)
end