Class: Spinoza::MetaLog::Entry

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Entry.



28
29
30
31
32
# File 'lib/spinoza/system/meta-log.rb', line 28

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

Instance Attribute Details

#nodeObject (readonly)

Node which wrote the entry.



16
17
18
# File 'lib/spinoza/system/meta-log.rb', line 16

def node
  @node
end

#time_quorumObject (readonly)

When, in the global timeline, this entry has reached a quorum and the writing node has been notified that this is the case.



23
24
25
# File 'lib/spinoza/system/meta-log.rb', line 23

def time_quorum
  @time_quorum
end

#time_replicatedObject (readonly)

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



26
27
28
# File 'lib/spinoza/system/meta-log.rb', line 26

def time_replicated
  @time_replicated
end

#valueObject (readonly)

Data payload.



19
20
21
# File 'lib/spinoza/system/meta-log.rb', line 19

def value
  @value
end

Instance Method Details

#quorum?Boolean

Returns true if the writing node knows the data is at a quorum.

Returns:

  • (Boolean)


35
36
37
# File 'lib/spinoza/system/meta-log.rb', line 35

def quorum?
  @node.time_now >= @time_quorum
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)


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

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