Class: Spinoza::MetaLog::Entry
- Inherits:
-
Object
- Object
- Spinoza::MetaLog::Entry
- Defined in:
- lib/spinoza/system/meta-log.rb
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Node which wrote the entry.
-
#time_quorum ⇒ Object
readonly
When, in the global timeline, this entry has reached a quorum and the writing node has been notified that this is the case.
-
#time_replicated ⇒ Object
readonly
When, in the global timeline, this entry is completely replicated.
-
#value ⇒ Object
readonly
Data payload.
Instance Method Summary collapse
-
#initialize(node: raise, value: raise, time_quorum: raise, time_replicated: raise) ⇒ Entry
constructor
A new instance of Entry.
-
#quorum? ⇒ Boolean
Returns true if the writing node knows the data is at a quorum.
-
#readable_at?(other_node) ⇒ Boolean
Returns true if
other_node
can read the entry (i.e. it has been replicated to the nodes).
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
#node ⇒ Object (readonly)
Node which wrote the entry.
16 17 18 |
# File 'lib/spinoza/system/meta-log.rb', line 16 def node @node end |
#time_quorum ⇒ Object (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_replicated ⇒ Object (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 |
#value ⇒ Object (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.
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).
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 |