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.



394
395
396
397
398
# File 'lib/omq/rust/engine.rb', line 394

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

Instance Method Details

#join(group) ⇒ Object



421
422
423
424
425
426
427
428
# File 'lib/omq/rust/engine.rb', line 421

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



431
432
433
# File 'lib/omq/rust/engine.rb', line 431

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

#replay_pending(native) ⇒ Object



436
437
438
439
440
441
# File 'lib/omq/rust/engine.rb', line 436

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



406
407
408
409
410
411
412
413
# File 'lib/omq/rust/engine.rb', line 406

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



401
402
403
# File 'lib/omq/rust/engine.rb', line 401

def subscriber_joined
  @engine.subscriber_joined
end

#unsubscribe(prefix) ⇒ Object



416
417
418
# File 'lib/omq/rust/engine.rb', line 416

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