Class: OsCtld::Container::RunId

Inherits:
Object
  • Object
show all
Defined in:
lib/osctld/container/run_id.rb

Overview

Identifies individual container runs

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pool_name:, container_id:, timestamp: nil) ⇒ RunId

Returns a new instance of RunId.

Parameters:

  • pool_name (String)
  • container_id (String)
  • timestamp (Float, nil) (defaults to: nil)


28
29
30
31
32
33
# File 'lib/osctld/container/run_id.rb', line 28

def initialize(pool_name:, container_id:, timestamp: nil)
  @pool_name = pool_name
  @container_id = container_id
  @timestamp = timestamp || Time.now.to_f
  @to_s = [@pool_name, @container_id, @timestamp].join(':')
end

Instance Attribute Details

#container_idString (readonly)

Returns:

  • (String)


8
9
10
# File 'lib/osctld/container/run_id.rb', line 8

def container_id
  @container_id
end

#pool_nameString (readonly)

Returns:

  • (String)


5
6
7
# File 'lib/osctld/container/run_id.rb', line 5

def pool_name
  @pool_name
end

#timestampFloat (readonly)

Returns:

  • (Float)


11
12
13
# File 'lib/osctld/container/run_id.rb', line 11

def timestamp
  @timestamp
end

#to_sString (readonly)

Returns:

  • (String)


14
15
16
# File 'lib/osctld/container/run_id.rb', line 14

def to_s
  @to_s
end

Class Method Details

.load(cfg) ⇒ Object

Parameters:

  • cfg (String)


17
18
19
20
21
22
23
# File 'lib/osctld/container/run_id.rb', line 17

def self.load(cfg)
  new(
    pool_name: cfg.fetch('pool_name'),
    container_id: cfg.fetch('container_id'),
    timestamp: cfg.fetch('timestamp')
  )
end

Instance Method Details

#==(other) ⇒ Object



39
40
41
# File 'lib/osctld/container/run_id.rb', line 39

def ==(other)
  to_s == other.to_s
end

#dumpObject



43
44
45
46
47
48
49
# File 'lib/osctld/container/run_id.rb', line 43

def dump
  {
    'pool_name' => pool_name,
    'container_id' => container_id,
    'timestamp' => timestamp
  }
end

#inspectObject



35
36
37
# File 'lib/osctld/container/run_id.rb', line 35

def inspect
  "#<#{self.class.name}:#{object_id} run=#{self}>"
end