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.



376
377
378
379
380
# File 'lib/omq/rust/engine.rb', line 376

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

Instance Method Details

#join(group) ⇒ Object



403
404
405
406
407
408
409
410
# File 'lib/omq/rust/engine.rb', line 403

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



413
414
415
# File 'lib/omq/rust/engine.rb', line 413

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

#replay_pending(native) ⇒ Object



418
419
420
421
422
423
# File 'lib/omq/rust/engine.rb', line 418

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



388
389
390
391
392
393
394
395
# File 'lib/omq/rust/engine.rb', line 388

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



383
384
385
# File 'lib/omq/rust/engine.rb', line 383

def subscriber_joined
  @engine.subscriber_joined
end

#unsubscribe(prefix) ⇒ Object



398
399
400
# File 'lib/omq/rust/engine.rb', line 398

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