Class: Async::App

Inherits:
Object
  • Object
show all
Extended by:
Injector
Includes:
Logger
Defined in:
lib/async/app.rb

Defined Under Namespace

Modules: Component, Injector Classes: EventLogger, WebServer

Instance Method Summary collapse

Methods included from Injector

inject

Constructor Details

#initializeApp

rubocop:disable Style/GlobalVars



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/async/app.rb', line 11

def initialize
  raise "only one instance of #{self.class} is allowed" if $__ASYNC_APP

  $__ASYNC_APP = self
  @task = Async::Task.current

  set_traps!
  init_container!

  start_event_logger!
  start_web_server!

  start_runtime_metrics_collector!

  run!

  info { "Started" }
  bus.publish("health.updated", true)
rescue StandardError => e
  fatal { e }
  stop
  exit(1)
end

Instance Method Details

#app_nameObject



38
# File 'lib/async/app.rb', line 38

def app_name = :async_app

#containerObject



35
# File 'lib/async/app.rb', line 35

def container = @container ||= Dry::Container.new

#container_configObject



37
# File 'lib/async/app.rb', line 37

def container_config = {}

#run!Object



36
# File 'lib/async/app.rb', line 36

def run! = nil

#stopObject



40
41
42
43
44
# File 'lib/async/app.rb', line 40

def stop
  @task&.stop
  $__ASYNC_APP = nil
  info { "Stopped" }
end