Class: Xtb::Config
- Inherits:
-
Object
- Object
- Xtb::Config
- Defined in:
- lib/xtb/config.rb
Overview
Configuration mapping for XTB API.
Constant Summary collapse
- DEFAULT_HTTP_HOST =
'xapi.xtb.com'
- DEFAULT_HTTP_PORT =
5124
- DEFAULT_WEB_SOCKET_HOST =
'ws.xtb.com'
- DEFAULT_WEB_SOCKET_PORT =
5125
- DEFAULT_WEB_SOCKET_PATH =
'demo'
- DEFAULT_CONNECTION_POOL_SIZE =
5
- MAX_CONNECTION_POOL_SIZE =
50
- MIN_REQUEST_INTERVAL =
in milliseconds
200
Class Method Summary collapse
- .connection_pool_size ⇒ Object
- .https_host ⇒ Object
- .https_port ⇒ Object
- .min_request_interval ⇒ Object
- .password ⇒ Object
- .user_id ⇒ Object
- .wss_host ⇒ Object
- .wss_path ⇒ Object
- .wss_port ⇒ Object
Class Method Details
.connection_pool_size ⇒ Object
44 45 46 47 48 49 |
# File 'lib/xtb/config.rb', line 44 def connection_pool_size size = ENV.fetch('XTB__CONNECTION_POOL_SIZE', DEFAULT_CONNECTION_POOL_SIZE).to_i raise "Max connection pool size is #{MAX_CONNECTION_POOL_SIZE}" if size > MAX_CONNECTION_POOL_SIZE size end |
.https_host ⇒ Object
16 17 18 |
# File 'lib/xtb/config.rb', line 16 def https_host ENV.fetch('XTB__HTTPS_HOST', DEFAULT_HTTP_HOST) end |
.https_port ⇒ Object
20 21 22 |
# File 'lib/xtb/config.rb', line 20 def https_port ENV.fetch('XTB__HTTPS_PORT', DEFAULT_HTTP_PORT).to_i end |
.min_request_interval ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/xtb/config.rb', line 51 def min_request_interval requests_interval = ENV.fetch('XTB__MIN_REQUEST_INTERVAL', MIN_REQUEST_INTERVAL).to_i if requests_interval < MIN_REQUEST_INTERVAL raise "Minimum request interval must be greater than or equal to #{MIN_REQUEST_INTERVAL}" end requests_interval end |
.password ⇒ Object
40 41 42 |
# File 'lib/xtb/config.rb', line 40 def password ENV.fetch('XTB__PASSWORD') { raise 'XTB__PASSWORD is required' } end |
.user_id ⇒ Object
36 37 38 |
# File 'lib/xtb/config.rb', line 36 def user_id ENV.fetch('XTB__USER_ID') { raise 'XTB__USER_ID is required' } end |
.wss_host ⇒ Object
24 25 26 |
# File 'lib/xtb/config.rb', line 24 def wss_host ENV.fetch('XTB__WSS_HOST', DEFAULT_WEB_SOCKET_HOST) end |
.wss_path ⇒ Object
28 29 30 |
# File 'lib/xtb/config.rb', line 28 def wss_path ENV.fetch('XTB__WSS_PATH', DEFAULT_WEB_SOCKET_PATH) end |
.wss_port ⇒ Object
32 33 34 |
# File 'lib/xtb/config.rb', line 32 def wss_port ENV.fetch('XTB__WSS_PORT', DEFAULT_WEB_SOCKET_PORT).to_i end |