Class: Kazoo::Partition
- Inherits:
-
Object
- Object
- Kazoo::Partition
- Defined in:
- lib/kazoo/partition.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#replicas ⇒ Object
readonly
Returns the value of attribute replicas.
-
#topic ⇒ Object
readonly
Returns the value of attribute topic.
Instance Method Summary collapse
- #cluster ⇒ Object
- #eql?(other) ⇒ Boolean (also: #==)
- #hash ⇒ Object
-
#initialize(topic, id, replicas: nil) ⇒ Partition
constructor
A new instance of Partition.
- #inspect ⇒ Object
- #isr ⇒ Object
- #leader ⇒ Object
- #replication_factor ⇒ Object
- #under_replicated? ⇒ Boolean
Constructor Details
#initialize(topic, id, replicas: nil) ⇒ Partition
Returns a new instance of Partition.
5 6 7 8 |
# File 'lib/kazoo/partition.rb', line 5 def initialize(topic, id, replicas: nil) @topic, @id, @replicas = topic, id, replicas @mutex = Mutex.new end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/kazoo/partition.rb', line 3 def id @id end |
#replicas ⇒ Object (readonly)
Returns the value of attribute replicas.
3 4 5 |
# File 'lib/kazoo/partition.rb', line 3 def replicas @replicas end |
#topic ⇒ Object (readonly)
Returns the value of attribute topic.
3 4 5 |
# File 'lib/kazoo/partition.rb', line 3 def topic @topic end |
Instance Method Details
#cluster ⇒ Object
10 11 12 |
# File 'lib/kazoo/partition.rb', line 10 def cluster topic.cluster end |
#eql?(other) ⇒ Boolean Also known as: ==
40 41 42 |
# File 'lib/kazoo/partition.rb', line 40 def eql?(other) other.kind_of?(Kazoo::Partition) && topic == other.topic && id == other.id end |
#hash ⇒ Object
46 47 48 |
# File 'lib/kazoo/partition.rb', line 46 def hash [topic, id].hash end |
#inspect ⇒ Object
36 37 38 |
# File 'lib/kazoo/partition.rb', line 36 def inspect "#<Kazoo::Partition #{topic.name}/#{id}>" end |
#isr ⇒ Object
25 26 27 28 29 30 |
# File 'lib/kazoo/partition.rb', line 25 def isr @mutex.synchronize do refresh_state if @isr.nil? @isr end end |
#leader ⇒ Object
18 19 20 21 22 23 |
# File 'lib/kazoo/partition.rb', line 18 def leader @mutex.synchronize do refresh_state if @leader.nil? @leader end end |
#replication_factor ⇒ Object
14 15 16 |
# File 'lib/kazoo/partition.rb', line 14 def replication_factor replicas.length end |
#under_replicated? ⇒ Boolean
32 33 34 |
# File 'lib/kazoo/partition.rb', line 32 def under_replicated? isr.length < replication_factor end |