Class: Longleaf::ServiceRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/longleaf/models/service_record.rb

Overview

Record for an individual service in a file’s metadata record.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(properties: Hash.new, stale_replicas: false, timestamp: nil, run_needed: false) ⇒ ServiceRecord

Returns a new instance of ServiceRecord.

Parameters:

  • properties (Hash) (defaults to: Hash.new)

    initial properties for this service record

  • stale_replicas (Boolean) (defaults to: false)

    whether there are any stale replicas from this service

  • timestamp (String) (defaults to: nil)

    timestamp when this service last ran or was initialized

  • run_needed (Boolean) (defaults to: false)

    flag indicating that this service should be run at the next available opportunity

Raises:

  • (ArgumentError)


12
13
14
15
16
17
18
19
# File 'lib/longleaf/models/service_record.rb', line 12

def initialize(properties: Hash.new, stale_replicas: false, timestamp: nil, run_needed: false)
  raise ArgumentError.new("Service properties must be a hash") if properties.class != Hash

  @properties = properties
  @timestamp = timestamp
  @stale_replicas = stale_replicas
  @run_needed = run_needed
end

Instance Attribute Details

#failure_timestampObject

Returns the value of attribute failure_timestamp.



6
7
8
# File 'lib/longleaf/models/service_record.rb', line 6

def failure_timestamp
  @failure_timestamp
end

#propertiesObject (readonly)

Returns the value of attribute properties.



4
5
6
# File 'lib/longleaf/models/service_record.rb', line 4

def properties
  @properties
end

#run_neededObject

Returns the value of attribute run_needed.



5
6
7
# File 'lib/longleaf/models/service_record.rb', line 5

def run_needed
  @run_needed
end

#stale_replicasObject

Returns the value of attribute stale_replicas.



5
6
7
# File 'lib/longleaf/models/service_record.rb', line 5

def stale_replicas
  @stale_replicas
end

#timestampObject

Returns the value of attribute timestamp.



5
6
7
# File 'lib/longleaf/models/service_record.rb', line 5

def timestamp
  @timestamp
end

Instance Method Details

#[](key) ⇒ Object

Returns the value of a service property identified by key.

Returns:

  • the value of a service property identified by key



22
23
24
# File 'lib/longleaf/models/service_record.rb', line 22

def [](key)
  @properties[key]
end

#[]=(key, value) ⇒ Object

set the value of a service property identified by key



27
28
29
# File 'lib/longleaf/models/service_record.rb', line 27

def []=(key, value)
  @properties[key] = value
end