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.



434
435
436
437
438
# File 'lib/omq/rust/engine.rb', line 434

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

Instance Method Details

#join(group) ⇒ Object



461
462
463
464
465
466
467
468
# File 'lib/omq/rust/engine.rb', line 461

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



471
472
473
# File 'lib/omq/rust/engine.rb', line 471

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

#replay_pending(native) ⇒ Object



476
477
478
479
480
481
# File 'lib/omq/rust/engine.rb', line 476

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



446
447
448
449
450
451
452
453
# File 'lib/omq/rust/engine.rb', line 446

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



441
442
443
# File 'lib/omq/rust/engine.rb', line 441

def subscriber_joined
  @engine.subscriber_joined
end

#unsubscribe(prefix) ⇒ Object



456
457
458
# File 'lib/omq/rust/engine.rb', line 456

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