Class: Trident::Worker

Inherits:
Struct
  • Object
show all
Defined in:
lib/trident/worker.rb

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pidObject

Returns the value of attribute pid

Returns:

  • (Object)

    the current value of pid



4
5
6
# File 'lib/trident/worker.rb', line 4

def pid
  @pid
end

#poolObject

Returns the value of attribute pool

Returns:

  • (Object)

    the current value of pool



4
5
6
# File 'lib/trident/worker.rb', line 4

def pool
  @pool
end

Instance Method Details

#created_atObject

We determine the time that this worker was created from the creation timestamp on its pidfile



22
23
24
# File 'lib/trident/worker.rb', line 22

def created_at
  @created_at ||= File.stat(path).ctime
end

#destroyObject

Remove the pidfile associated with this worker



15
16
17
# File 'lib/trident/worker.rb', line 15

def destroy
  FileUtils.rm path if File.exists?(path)
end

#saveObject

Crate a pidfile for this worker so that we may track it



7
8
9
10
11
# File 'lib/trident/worker.rb', line 7

def save
  File.open(path, 'w') do |f|
    f << "#{pid}"
  end
end