Module: Nutella::App
- Defined in:
- lib/nutella_lib/app_log.rb,
lib/nutella_lib/app_net.rb,
lib/nutella_lib/app_core.rb,
lib/nutella_lib/app_persist.rb
Defined Under Namespace
Class Method Summary collapse
- .app_runs_list ⇒ Object
-
.app_runs_list=(val) ⇒ Object
Setter/getter for runs_list.
-
.extract_component_id ⇒ String
Extracts the component name from the folder where the code for this component is located.
-
.init(broker_hostname, app_id, component_id) ⇒ Object
Initializes this component as an application component.
- .log ⇒ Object
-
.net ⇒ Object
Accessors for sub-modules.
-
.parse_args(args) ⇒ String
Parse command line arguments for app level components.
- .persist ⇒ Object
-
.set_resource_id(resource_id) ⇒ Object
Sets the resource id.
Class Method Details
.app_runs_list ⇒ Object
24 25 26 27 |
# File 'lib/nutella_lib/app_core.rb', line 24 def self.app_runs_list raise 'Nutella has not been initialized: you need to call the proper init method before you can start using nutella' if @app_runs_list.nil? @app_runs_list end |
.app_runs_list=(val) ⇒ Object
Setter/getter for runs_list
23 |
# File 'lib/nutella_lib/app_core.rb', line 23 def self.app_runs_list=(val) @app_runs_list=val; end |
.extract_component_id ⇒ String
Extracts the component name from the folder where the code for this component is located
50 51 52 |
# File 'lib/nutella_lib/app_core.rb', line 50 def self.extract_component_id Nutella.extract_component_id end |
.init(broker_hostname, app_id, component_id) ⇒ Object
Initializes this component as an application component
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/nutella_lib/app_core.rb', line 8 def self.init( broker_hostname, app_id, component_id ) Nutella.app_id = app_id Nutella.run_id = nil Nutella.component_id = component_id Nutella.resource_id = nil Nutella.mongo_host = broker_hostname Nutella.mqtt = SimpleMQTTClient.new broker_hostname # Start pinging Nutella.net.start_pinging # Fetch the `run_id`s list for this application and subscribe to its updates net.async_request('app_runs_list', lambda { |res| Nutella.app.app_runs_list = res }) self.net.subscribe('app_runs_list', lambda {|, _| Nutella.app.app_runs_list = }) end |
.net ⇒ Object
Accessors for sub-modules
30 |
# File 'lib/nutella_lib/app_core.rb', line 30 def self.net; Nutella::App::Net; end |
.parse_args(args) ⇒ String
Parse command line arguments for app level components
39 40 41 42 43 44 45 |
# File 'lib/nutella_lib/app_core.rb', line 39 def self.parse_args(args) if args.length < 2 STDERR.puts 'Couldn\'t read broker address and app_id from the command line, impossible to initialize component!' return end return args[0], args[1] end |
.persist ⇒ Object
32 |
# File 'lib/nutella_lib/app_core.rb', line 32 def self.persist; Nutella::App::Persist; end |
.set_resource_id(resource_id) ⇒ Object
Sets the resource id
57 58 59 |
# File 'lib/nutella_lib/app_core.rb', line 57 def self.set_resource_id( resource_id ) Nutella.set_resource_id resource_id end |