Class: NetworkClient
- Inherits:
-
Object
- Object
- NetworkClient
- Defined in:
- lib/wingify/packages/network_layer/client/network_client.rb
Constant Summary collapse
- HTTPS_SCHEME =
'https'
Instance Method Summary collapse
- #get(request_model) ⇒ Object
- #get_should_use_threading ⇒ Object
- #get_thread_pool ⇒ Object
-
#initialize(options = {}) ⇒ NetworkClient
constructor
A new instance of NetworkClient.
- #post(request_model) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ NetworkClient
Returns a new instance of NetworkClient.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/wingify/packages/network_layer/client/network_client.rb', line 31 def initialize( = {}) # options for threading @should_use_threading = .key?(:enabled) ? [:enabled] : Constants::SHOULD_USE_THREADING @thread_pool = Concurrent::ThreadPoolExecutor.new( # Minimum number of threads to keep alive in the pool min_threads: 1, # Maximum number of threads allowed in the pool, configurable via options or defaults to MAX_POOL_SIZE constant max_threads: .key?(:max_pool_size) ? [:max_pool_size] : Constants::MAX_POOL_SIZE, # Maximum number of tasks that can be queued when all threads are busy max_queue: .key?(:max_queue_size) ? [:max_queue_size] : Constants::MAX_QUEUE_SIZE, # When queue is full, execute task in the caller's thread rather than rejecting it fallback_policy: :caller_runs ) end |
Instance Method Details
#get(request_model) ⇒ Object
54 55 56 |
# File 'lib/wingify/packages/network_layer/client/network_client.rb', line 54 def get(request_model) execute_with_retry(request_model, :get_request) end |
#get_should_use_threading ⇒ Object
50 51 52 |
# File 'lib/wingify/packages/network_layer/client/network_client.rb', line 50 def get_should_use_threading @should_use_threading end |
#get_thread_pool ⇒ Object
46 47 48 |
# File 'lib/wingify/packages/network_layer/client/network_client.rb', line 46 def get_thread_pool @thread_pool end |
#post(request_model) ⇒ Object
58 59 60 |
# File 'lib/wingify/packages/network_layer/client/network_client.rb', line 58 def post(request_model) execute_with_retry(request_model, :post_request) end |