Module: KubeQueue::Worker
- Defined in:
- lib/kube_queue/worker.rb,
lib/kube_queue/worker/dsl.rb
Defined Under Namespace
Modules: ClassMethods, DSL
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#arguments ⇒ Object
Also known as:
payload
Returns the value of attribute arguments.
100
101
102
|
# File 'lib/kube_queue/worker.rb', line 100
def arguments
@arguments
end
|
#job_id ⇒ Object
Returns the value of attribute job_id.
99
100
101
|
# File 'lib/kube_queue/worker.rb', line 99
def job_id
@job_id
end
|
#resource ⇒ Object
Returns the value of attribute resource.
100
101
102
|
# File 'lib/kube_queue/worker.rb', line 100
def resource
@resource
end
|
#scheduled_at ⇒ Object
Returns the value of attribute scheduled_at.
99
100
101
|
# File 'lib/kube_queue/worker.rb', line 99
def scheduled_at
@scheduled_at
end
|
Instance Method Details
#initialize(*arguments) ⇒ Object
104
105
106
107
108
109
110
111
112
113
114
115
|
# File 'lib/kube_queue/worker.rb', line 104
def initialize(*arguments)
if method(__method__).super_method.arity.zero?
super()
else
super
end
@arguments = arguments
@job_id = SecureRandom.uuid
@loaded = false
end
|
#job_spec ⇒ Object
95
96
97
|
# File 'lib/kube_queue/worker.rb', line 95
def job_spec
self.class.job_spec
end
|
#loaded? ⇒ Boolean
136
137
138
|
# File 'lib/kube_queue/worker.rb', line 136
def loaded?
@loaded
end
|
124
125
126
|
# File 'lib/kube_queue/worker.rb', line 124
def perform(*)
raise NotImplementedError
end
|
117
118
119
120
121
122
|
# File 'lib/kube_queue/worker.rb', line 117
def perform_now
return super if defined?(super)
perform(*arguments)
end
|
#read_template ⇒ Object
91
92
93
|
# File 'lib/kube_queue/worker.rb', line 91
def read_template
self.class.read_template
end
|
#reload! ⇒ Object
140
141
142
143
144
145
|
# File 'lib/kube_queue/worker.rb', line 140
def reload!
@loaded = false
@resource = nil
load_target
end
|
#serialized_payload ⇒ Object
157
158
159
160
161
162
163
|
# File 'lib/kube_queue/worker.rb', line 157
def serialized_payload
if self.class.active_job?
ActiveJob::Arguments.serialize(arguments)
else
arguments
end
end
|
#status ⇒ Object
128
129
130
131
132
133
134
|
# File 'lib/kube_queue/worker.rb', line 128
def status
return @resource.status if loaded?
load_target
@resource.status
end
|