Module: Izanami::Worker::InstanceMethods

Defined in:
lib/izanami/worker.rb

Instance Method Summary collapse

Instance Method Details

#callObject

Main worker action. Must be defined in the concrete class.



49
50
51
# File 'lib/izanami/worker.rb', line 49

def call
  raise 'The method #call should be defined in the worker class'
end

#deferString, Fixnum

Note:

the process forked is detached.

Executes a #call method in a different process, forking the current one.

Returns:

  • (String, Fixnum)

    the new process pid.



41
42
43
44
45
46
# File 'lib/izanami/worker.rb', line 41

def defer
  pid = Process.fork { call }
  Process.detach(pid)

  pid
end

#runObject

See Also:

  • Izanami::Worker::InstanceMethods.{{#call}


54
55
56
# File 'lib/izanami/worker.rb', line 54

def run
  call
end