Class: Spinoza::Log::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/spinoza/system/log.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node: raise, value: raise, time_durable: raise, time_replicated: raise) ⇒ Entry

Returns a new instance of Entry.



34
35
36
37
38
# File 'lib/spinoza/system/log.rb', line 34

def initialize node: raise, value: raise,
    time_durable: raise, time_replicated: raise
  @node, @value, @time_durable, @time_replicated =
    node, value, time_durable, time_replicated
end

Instance Attribute Details

#nodeObject (readonly)

Node which wrote the entry.



22
23
24
# File 'lib/spinoza/system/log.rb', line 22

def node
  @node
end

#time_durableObject (readonly)

When, in the global timeline, this entry is durable enough and the writing node has been notified that this is the case.



29
30
31
# File 'lib/spinoza/system/log.rb', line 29

def time_durable
  @time_durable
end

#time_replicatedObject (readonly)

When, in the global timeline, this entry is completely replicated.



32
33
34
# File 'lib/spinoza/system/log.rb', line 32

def time_replicated
  @time_replicated
end

#valueObject (readonly)

Data payload.



25
26
27
# File 'lib/spinoza/system/log.rb', line 25

def value
  @value
end

Instance Method Details

#durable?Boolean

Returns true if the writing node believes the data to be durable.

Returns:

  • (Boolean)


41
42
43
# File 'lib/spinoza/system/log.rb', line 41

def durable?
  @node.time_now >= @time_durable
end

#readable_at?(other_node) ⇒ Boolean

Returns true if other_node can read the entry (i.e. it has been replicated to the nodes).

Returns:

  • (Boolean)


47
48
49
# File 'lib/spinoza/system/log.rb', line 47

def readable_at? other_node
  other_node == @node or other_node.time_now >= @time_replicated
end