Class: Stellwerk::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/stellwerk/configuration.rb

Overview

Configuration class for Stellwerk SDK settings

Examples:

Stellwerk.configure do |config|
  config.api_key = 'sk_stellwerk_...'
  config.api_url = 'https://stellwerk.io'
end

Constant Summary collapse

DEFAULT_API_URL =

Default API URL

"https://stellwerk.io"
DEFAULT_SYNC_INTERVAL =

Default sync interval (60 seconds)

60
DEFAULT_OFFLINE_GRACE_PERIOD =

Default offline grace period (24 hours)

86_400
DEFAULT_OFFLINE_GRACE_EXECUTIONS =

Default offline grace executions

100

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Configuration

Returns a new instance of Configuration.



53
54
55
56
57
58
59
60
61
# File 'lib/stellwerk/configuration.rb', line 53

def initialize
  @api_key = nil
  @api_url = DEFAULT_API_URL
  @sync_interval = DEFAULT_SYNC_INTERVAL
  @offline_grace_period = DEFAULT_OFFLINE_GRACE_PERIOD
  @offline_grace_executions = DEFAULT_OFFLINE_GRACE_EXECUTIONS
  @logger = nil
  @verify_ssl = true
end

Instance Attribute Details

#api_key ⇒ String?

API key for license validation and metering

Returns:

  • (String, nil)


15
16
17
# File 'lib/stellwerk/configuration.rb', line 15

def api_key
  @api_key
end

#api_url ⇒ String

Base URL for the Stellwerk API

Returns:

  • (String)


19
20
21
# File 'lib/stellwerk/configuration.rb', line 19

def api_url
  @api_url
end

#logger ⇒ Logger

Logger instance

Returns:

  • (Logger)


35
36
37
# File 'lib/stellwerk/configuration.rb', line 35

def logger
  @logger
end

#offline_grace_executions ⇒ Integer

Maximum executions allowed during offline grace period

Returns:

  • (Integer)


31
32
33
# File 'lib/stellwerk/configuration.rb', line 31

def offline_grace_executions
  @offline_grace_executions
end

#offline_grace_period ⇒ Integer

Maximum seconds to allow offline operation when server is unreachable

Returns:

  • (Integer)


27
28
29
# File 'lib/stellwerk/configuration.rb', line 27

def offline_grace_period
  @offline_grace_period
end

#sync_interval ⇒ Integer

Interval in seconds between batch metering reports

Returns:

  • (Integer)


23
24
25
# File 'lib/stellwerk/configuration.rb', line 23

def sync_interval
  @sync_interval
end

#verify_ssl ⇒ Boolean

Whether to verify SSL certificates (disable for development only)

Returns:

  • (Boolean)


39
40
41
# File 'lib/stellwerk/configuration.rb', line 39

def verify_ssl
  @verify_ssl
end

Instance Method Details

#api_key? ⇒ Boolean

Check if an API key is configured

Returns:

  • (Boolean)


65
66
67
# File 'lib/stellwerk/configuration.rb', line 65

def api_key?
  !@api_key.nil? && !@api_key.empty?
end

#reset! ⇒ Object

Reset configuration to defaults



70
71
72
73
74
75
76
77
78
# File 'lib/stellwerk/configuration.rb', line 70

def reset!
  @api_key = nil
  @api_url = DEFAULT_API_URL
  @sync_interval = DEFAULT_SYNC_INTERVAL
  @offline_grace_period = DEFAULT_OFFLINE_GRACE_PERIOD
  @offline_grace_executions = DEFAULT_OFFLINE_GRACE_EXECUTIONS
  @logger = nil
  @verify_ssl = true
end