Class: Pulsar::MessageId

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/pulsar/message_id.rb

Overview

Comparable Pulsar message identifier.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ledger_id:, entry_id:, partition_index: -1,, batch_index: -1)) ⇒ MessageId

Returns a new instance of MessageId.



10
11
12
13
14
15
16
# File 'lib/pulsar/message_id.rb', line 10

def initialize(ledger_id:, entry_id:, partition_index: -1, batch_index: -1)
  @ledger_id = Integer(ledger_id)
  @entry_id = Integer(entry_id)
  @partition_index = Integer(partition_index)
  @batch_index = Integer(batch_index)
  freeze
end

Instance Attribute Details

#batch_indexObject (readonly)

Returns the value of attribute batch_index.



8
9
10
# File 'lib/pulsar/message_id.rb', line 8

def batch_index
  @batch_index
end

#entry_idObject (readonly)

Returns the value of attribute entry_id.



8
9
10
# File 'lib/pulsar/message_id.rb', line 8

def entry_id
  @entry_id
end

#ledger_idObject (readonly)

Returns the value of attribute ledger_id.



8
9
10
# File 'lib/pulsar/message_id.rb', line 8

def ledger_id
  @ledger_id
end

#partition_indexObject (readonly)

Returns the value of attribute partition_index.



8
9
10
# File 'lib/pulsar/message_id.rb', line 8

def partition_index
  @partition_index
end

Instance Method Details

#<=>(other) ⇒ Object



18
19
20
21
22
# File 'lib/pulsar/message_id.rb', line 18

def <=>(other)
  return nil unless other.is_a?(MessageId)

  to_a <=> other.to_a
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/pulsar/message_id.rb', line 24

def eql?(other)
  other.is_a?(MessageId) && to_a == other.to_a
end

#hashObject



28
29
30
# File 'lib/pulsar/message_id.rb', line 28

def hash
  to_a.hash
end

#inspectObject



32
33
34
35
# File 'lib/pulsar/message_id.rb', line 32

def inspect
  "#<#{self.class.name} ledger_id=#{ledger_id} entry_id=#{entry_id} " \
    "partition_index=#{partition_index} batch_index=#{batch_index}>"
end