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.



290
291
292
293
294
# File 'lib/omq/rust/engine.rb', line 290

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

Instance Method Details

#join(group) ⇒ Object



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

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



327
328
329
# File 'lib/omq/rust/engine.rb', line 327

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

#replay_pending(native) ⇒ Object



332
333
334
335
336
337
# File 'lib/omq/rust/engine.rb', line 332

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



302
303
304
305
306
307
308
309
# File 'lib/omq/rust/engine.rb', line 302

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



297
298
299
# File 'lib/omq/rust/engine.rb', line 297

def subscriber_joined
  @engine.subscriber_joined
end

#unsubscribe(prefix) ⇒ Object



312
313
314
# File 'lib/omq/rust/engine.rb', line 312

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