lib/karafka/processing/jobs/base.rb in karafka-2.0.0.beta3 vs lib/karafka/processing/jobs/base.rb in karafka-2.0.0.beta4
- old
+ new
@@ -3,11 +3,11 @@
module Karafka
module Processing
# Namespace for all the jobs that are suppose to run in workers.
module Jobs
# Base class for all the jobs types that are suppose to run in workers threads.
- # Each job can have 3 main entry-points: `#prepare`, `#call` and `#teardown`
+ # Each job can have 3 main entry-points: `#before_call`, `#call` and `#after_call`
# Only `#call` is required.
class Base
extend Forwardable
# @note Since one job has always one executer, we use the jobs id and group id as reference
@@ -21,13 +21,18 @@
# are done (if needed)
@non_blocking = false
end
# When redefined can run any code that should run before executing the proper code
- def prepare; end
+ def before_call; end
+ # The main entry-point of a job
+ def call
+ raise NotImplementedError, 'Please implement in a subclass'
+ end
+
# When redefined can run any code that should run after executing the proper code
- def teardown; end
+ def after_call; end
# @return [Boolean] is this a non-blocking job
#
# @note Blocking job is a job, that will cause the job queue to wait until it is finished
# before removing the lock on new jobs being added