Class: StatsCloud::Client

Inherits:
Object
  • Object
show all
Includes:
Singleton, AssetsHelper, LoggerHelper, StatsCloudHelper
Defined in:
lib/statscloud/statscloud_client.rb

Overview

Module which implements StatsCloud framework support.

Instance Method Summary collapse

Methods included from LoggerHelper

#logger

Instance Method Details

#cluster_statusHash

Returns cluster status.

Returns:

  • (Hash)


74
75
76
77
78
# File 'lib/statscloud/statscloud_client.rb', line 74

def cluster_status
  return unless @cluster_client
  cluster = @cluster_client.get_cluster(@token, @app)&.body
  cluster[:status][:status] if cluster
end

#meterStatsCloud::StatsmeterClient

Returns statscloud.io client aka Statsmeter client



65
66
67
# File 'lib/statscloud/statscloud_client.rb', line 65

def meter
  @statsmeter_client
end

#start(base_config = nil) ⇒ Thread

Configures statsmeter.io support for application and initializes a statscloud.io client.

Parameters:

  • env (+String)

    statsmeter.io cluster environment

  • base_config (+Hash+) (defaults to: nil)

    statsmeter.io configuration

Returns:

  • (Thread)


34
35
36
37
38
39
40
41
42
# File 'lib/statscloud/statscloud_client.rb', line 34

def start(base_config = nil)
  initialize_values
  generate_configuration(base_config)
  collect_statscloud_assets(@config, @source_mappings)
  config_values
  clear_data
  configure_cluster
  connect_to_cluster
end

#stopNilClass

Stops statscloud.io service.

Returns:

  • (NilClass)


85
86
87
88
89
90
# File 'lib/statscloud/statscloud_client.rb', line 85

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.

Returns:

  • StatsCloud::Client



47
48
49
50
# File 'lib/statscloud/statscloud_client.rb', line 47

def with_environment(env)
  config_environment(env)
  self
end

#with_tags(tags) ⇒ Object

Configures Statscloud tags.

Returns:

  • StatsCloud::Client



55
56
57
58
# File 'lib/statscloud/statscloud_client.rb', line 55

def with_tags(tags)
  config_tags(tags)
  self
end