Class: Logux::Node
Instance Attribute Summary collapse
-
#last_time ⇒ Object
Returns the value of attribute last_time.
- #node_id ⇒ Object
-
#sequence ⇒ Object
Returns the value of attribute sequence.
Instance Method Summary collapse
Instance Attribute Details
#last_time ⇒ Object
Returns the value of attribute last_time.
7 8 9 |
# File 'lib/logux/node.rb', line 7 def last_time @last_time end |
#node_id ⇒ Object
23 24 25 |
# File 'lib/logux/node.rb', line 23 def node_id @node_id ||= "server:#{Nanoid.generate(size: 8)}" end |
#sequence ⇒ Object
Returns the value of attribute sequence.
7 8 9 |
# File 'lib/logux/node.rb', line 7 def sequence @sequence end |
Instance Method Details
#generate_action_id ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/logux/node.rb', line 10 def generate_action_id mutex.synchronize do if last_time && now_time <= last_time @sequence += 1 else @sequence = 0 @last_time = now_time end "#{last_time} #{node_id} #{sequence}" end end |