Class: OMQ::Rust::Engine::RoutingStub

Inherits:
Object
  • Object
show all
Defined in:
lib/omq/rust/engine.rb

Instance Method Summary collapse

Constructor Details

#initialize(engine) ⇒ RoutingStub

Returns a new instance of RoutingStub.



307
308
309
310
311
# File 'lib/omq/rust/engine.rb', line 307

def initialize(engine)
  @engine            = engine
  @pending_subscribe = []
  @pending_join      = []
end

Instance Method Details

#join(group) ⇒ Object



334
335
336
337
338
339
340
341
# File 'lib/omq/rust/engine.rb', line 334

def join(group)
  native = @engine.instance_variable_get(:@native)
  if @engine.instance_variable_get(:@materialized)
    native.join(group)
  else
    @pending_join << group
  end
end

#leave(group) ⇒ Object



344
345
346
# File 'lib/omq/rust/engine.rb', line 344

def leave(group)
  @engine.instance_variable_get(:@native).leave(group)
end

#replay_pending(native) ⇒ Object



349
350
351
352
353
354
# File 'lib/omq/rust/engine.rb', line 349

def replay_pending(native)
  @pending_subscribe.each { |p| native.subscribe(p) }
  @pending_subscribe.clear
  @pending_join.each { |g| native.join(g) }
  @pending_join.clear
end

#subscribe(prefix) ⇒ Object



319
320
321
322
323
324
325
326
# File 'lib/omq/rust/engine.rb', line 319

def subscribe(prefix)
  native = @engine.instance_variable_get(:@native)
  if @engine.instance_variable_get(:@materialized)
    native.subscribe(prefix.b)
  else
    @pending_subscribe << prefix.b
  end
end

#subscriber_joinedObject



314
315
316
# File 'lib/omq/rust/engine.rb', line 314

def subscriber_joined
  @engine.subscriber_joined
end

#unsubscribe(prefix) ⇒ Object



329
330
331
# File 'lib/omq/rust/engine.rb', line 329

def unsubscribe(prefix)
  @engine.instance_variable_get(:@native).unsubscribe(prefix.b)
end