Class: Realm::Runtime

Inherits:
Object
  • Object
show all
Defined in:
lib/realm/runtime.rb,
lib/realm/runtime/session.rb

Defined Under Namespace

Classes: Session

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(container = Container.new) ⇒ Runtime

Returns a new instance of Runtime.



20
21
22
# File 'lib/realm/runtime.rb', line 20

def initialize(container = Container.new)
  @container = Container[container]
end

Instance Attribute Details

#containerObject (readonly)

Returns the value of attribute container.



18
19
20
# File 'lib/realm/runtime.rb', line 18

def container
  @container
end

Instance Method Details

#active_queuesObject

Get all active messaging queues. For maintenance purpose only. TODO: Introduce component container and allow to call those method directly on components instead of polluting runtime Example: engine.realm.components.find(type: Realm::EventRouter::SNSGateway).try(:active_queues)



47
48
49
# File 'lib/realm/runtime.rb', line 47

def active_queues
  event_router.try(:active_queues) || []
end

#contextObject



24
25
26
# File 'lib/realm/runtime.rb', line 24

def context
  @context ||= Context.new(@container)
end

#healthObject



36
37
38
39
40
41
# File 'lib/realm/runtime.rb', line 36

def health
  component_statuses = container.each_with_object({}) do |(name, component), map|
    map[name] = component.health if component.respond_to?(:health) && !component.is_a?(Runtime)
  end
  HealthStatus.combine(component_statuses)
end

#session(context = {}) ⇒ Object



28
29
30
# File 'lib/realm/runtime.rb', line 28

def session(context = {})
  context.blank? ? self : Session.new(self, context)
end

#worker(*args) ⇒ Object



32
33
34
# File 'lib/realm/runtime.rb', line 32

def worker(*args)
  MultiWorker.new(event_router.try(:workers, *args) || [])
end