Class: Crontinel::WorkerState

Inherits:
Object
  • Object
show all
Defined in:
lib/crontinel.rb

Overview

Represents a worker's current state

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ WorkerState

Returns a new instance of WorkerState.



60
61
62
63
64
65
66
# File 'lib/crontinel.rb', line 60

def initialize(attrs = {})
  @name = attrs["name"]
  @status = attrs["status"] || "unknown"
  @jobs_processed = attrs["processed"] || attrs["jobs_processed"] || 0
  @jobs_failed = attrs["failed"] || attrs["jobs_failed"] || 0
  @memory_mb = attrs["memory_mb"]
end

Instance Attribute Details

#jobs_failedObject (readonly)

Returns the value of attribute jobs_failed.



58
59
60
# File 'lib/crontinel.rb', line 58

def jobs_failed
  @jobs_failed
end

#jobs_processedObject (readonly)

Returns the value of attribute jobs_processed.



58
59
60
# File 'lib/crontinel.rb', line 58

def jobs_processed
  @jobs_processed
end

#memory_mbObject (readonly)

Returns the value of attribute memory_mb.



58
59
60
# File 'lib/crontinel.rb', line 58

def memory_mb
  @memory_mb
end

#nameObject (readonly)

Returns the value of attribute name.



58
59
60
# File 'lib/crontinel.rb', line 58

def name
  @name
end

#statusObject (readonly)

Returns the value of attribute status.



58
59
60
# File 'lib/crontinel.rb', line 58

def status
  @status
end

Instance Method Details

#alive?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/crontinel.rb', line 68

def alive?
  @status == "running" || @status == "active"
end