Class: Kcl::Workers::ShardInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/kcl/workers/shard_info.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(shard_id, parent_shard_id, sequence_number_range) ⇒ ShardInfo

Returns a new instance of ShardInfo.

Parameters:

  • shard_id (String)
  • parent_shard_id (String)
  • sequence_number_range (Hash)


12
13
14
15
16
17
18
19
20
# File 'lib/kcl/workers/shard_info.rb', line 12

def initialize(shard_id, parent_shard_id, sequence_number_range)
  @shard_id        = shard_id
  @parent_shard_id = parent_shard_id || 0
  @starting_sequence_number = sequence_number_range[:starting_sequence_number]
  @ending_sequence_number   = sequence_number_range[:ending_sequence_number]
  @assigned_to     = nil
  @checkpoint      = nil
  @lease_timeout   = nil
end

Instance Attribute Details

#assigned_toObject

Returns the value of attribute assigned_to.



7
8
9
# File 'lib/kcl/workers/shard_info.rb', line 7

def assigned_to
  @assigned_to
end

#checkpointObject

Returns the value of attribute checkpoint.



7
8
9
# File 'lib/kcl/workers/shard_info.rb', line 7

def checkpoint
  @checkpoint
end

#ending_sequence_numberObject (readonly)

Returns the value of attribute ending_sequence_number.



3
4
5
# File 'lib/kcl/workers/shard_info.rb', line 3

def ending_sequence_number
  @ending_sequence_number
end

#lease_timeoutObject

Returns the value of attribute lease_timeout.



7
8
9
# File 'lib/kcl/workers/shard_info.rb', line 7

def lease_timeout
  @lease_timeout
end

#parent_shard_idObject (readonly)

Returns the value of attribute parent_shard_id.



3
4
5
# File 'lib/kcl/workers/shard_info.rb', line 3

def parent_shard_id
  @parent_shard_id
end

#shard_idObject (readonly)

Returns the value of attribute shard_id.



3
4
5
# File 'lib/kcl/workers/shard_info.rb', line 3

def shard_id
  @shard_id
end

#starting_sequence_numberObject (readonly)

Returns the value of attribute starting_sequence_number.



3
4
5
# File 'lib/kcl/workers/shard_info.rb', line 3

def starting_sequence_number
  @starting_sequence_number
end

Instance Method Details

#completed?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/kcl/workers/shard_info.rb', line 30

def completed?
  @checkpoint == Kcl::Checkpoints::Sentinel::SHARD_END
end

#lease_ownerObject



22
23
24
# File 'lib/kcl/workers/shard_info.rb', line 22

def lease_owner
  @assigned_to
end

#lease_owner=(assigned_to) ⇒ Object



26
27
28
# File 'lib/kcl/workers/shard_info.rb', line 26

def lease_owner=(assigned_to)
  @assigned_to = assigned_to
end

#to_hObject

For debug



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/kcl/workers/shard_info.rb', line 35

def to_h
  {
    shard_id: shard_id,
    parent_shard_id: parent_shard_id,
    starting_sequence_number: starting_sequence_number,
    ending_sequence_number: ending_sequence_number,
    assigned_to: assigned_to,
    checkpoint: checkpoint,
    lease_timeout: lease_timeout
  }
end