Class: StatsCloud::Client
- Inherits:
-
Object
- Object
- StatsCloud::Client
- Includes:
- Singleton, AssetsHelper, LoggerHelper, PluginsHelper, StatsCloudHelper
- Defined in:
- lib/statscloud/statscloud_client.rb
Overview
Module which implements StatsCloud framework support.
Instance Method Summary collapse
-
#cluster_status ⇒ Hash
Returns cluster status.
-
#meter ⇒ StatsCloud::StatsmeterClient
Returns statscloud.io client aka Statsmeter client.
-
#record_event(name, measurement = 0) ⇒ Object
Records a single event.
-
#record_events(*events) ⇒ Object
Records several events at once.
-
#record_events_array(events) ⇒ Object
Records an array of events at once.
-
#start(base_config = nil) ⇒ Thread
Configures statsmeter.io support for application and initializes a statscloud.io client.
-
#stop ⇒ NilClass
Stops statscloud.io service.
-
#with_environment(env) ⇒ Object
Configures Statscloud environment.
-
#with_tags(tags) ⇒ Object
Configures Statscloud tags.
Methods included from PluginsHelper
#build_plugins, #start_plugins_job
Methods included from LoggerHelper
#log_error, #log_info, #logger
Instance Method Details
#cluster_status ⇒ Hash
Returns cluster status.
109 110 111 112 113 114 115 |
# File 'lib/statscloud/statscloud_client.rb', line 109 def cluster_status return unless @cluster_client cluster = @cluster_client.get_cluster(@token, @app)&.body check_cluster_status(cluster) cluster[:status][:status] if cluster end |
#meter ⇒ StatsCloud::StatsmeterClient
Returns statscloud.io client aka Statsmeter client
68 69 70 |
# File 'lib/statscloud/statscloud_client.rb', line 68 def meter @statsmeter_client end |
#record_event(name, measurement = 0) ⇒ Object
Records a single event.
Calls statsmeter client record_event method.
80 81 82 |
# File 'lib/statscloud/statscloud_client.rb', line 80 def record_event(name, measurement = 0) @statsmeter_client&.record_event(name, measurement) end |
#record_events(*events) ⇒ Object
Records several events at once.
Calls statsmeter record_events method.
90 91 92 |
# File 'lib/statscloud/statscloud_client.rb', line 90 def record_events(*events) @statsmeter_client&.record_events(*events) end |
#record_events_array(events) ⇒ Object
Records an array of events at once.
Calls statsmeter client record_events_array method.
100 101 102 |
# File 'lib/statscloud/statscloud_client.rb', line 100 def record_events_array(events) @statsmeter_client&.record_events_array(events) end |
#start(base_config = nil) ⇒ Thread
Configures statsmeter.io support for application and initializes a statscloud.io client.
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/statscloud/statscloud_client.rb', line 36 def start(base_config = nil) initialize_values generate_configuration(base_config) collect_statscloud_assets(@config, @source_mappings) config_values clear_data configure_statscloud_plugins configure_cluster connect_to_cluster end |
#stop ⇒ NilClass
Stops statscloud.io service.
122 123 124 125 126 127 |
# File 'lib/statscloud/statscloud_client.rb', line 122 def stop @statsmeter_client&.close @statsmeter_client = nil @cluster_client&.undeploy_cluster(@token, @app) @cluster_client = nil end |
#with_environment(env) ⇒ Object
Configures Statscloud environment.
50 51 52 53 |
# File 'lib/statscloud/statscloud_client.rb', line 50 def with_environment(env) config_environment(env) self end |
#with_tags(tags) ⇒ Object
Configures Statscloud tags.
58 59 60 61 |
# File 'lib/statscloud/statscloud_client.rb', line 58 def () () self end |