Class: PulsarSdk::Producer::SeqGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/pulsar_sdk/producer/base.rb

Overview

NOTE keep producer_id and sequence_id static

Instance Method Summary collapse

Constructor Details

#initialize(seq_g) ⇒ SeqGenerator

Returns a new instance of SeqGenerator.



134
135
136
137
138
# File 'lib/pulsar_sdk/producer/base.rb', line 134

def initialize(seq_g)
  @seq_g = seq_g
  @producer_id = @seq_g.new_producer_id
  @sequence_id = @seq_g.new_sequence_id
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method) ⇒ Object



149
150
151
# File 'lib/pulsar_sdk/producer/base.rb', line 149

def method_missing(method)
  @seq_g.public_send(method)
end

Instance Method Details

#new_producer_idObject



140
141
142
# File 'lib/pulsar_sdk/producer/base.rb', line 140

def new_producer_id
  @producer_id
end

#new_sequence_id(cache = true) ⇒ Object



144
145
146
147
# File 'lib/pulsar_sdk/producer/base.rb', line 144

def new_sequence_id(cache = true)
  return @sequence_id if cache
  @sequence_id = @seq_g.new_sequence_id
end