Class: CDP::Client
- Inherits:
-
Object
- Object
- CDP::Client
- Includes:
- Retryable, Configuration
- Defined in:
- lib/cdp/client.rb
Constant Summary collapse
- AVAILABLE_PRIORITIES =
%i[low normal high]
Constants included from Configuration
Configuration::CDP_CORE_SERVICE_URL
Constants included from Retryable
Retryable::CDP_CLIENT_RETRYABLE_ERRORS, Retryable::DEFAULT_CDP_CLIENT_RETRYABLE_ERRORS
Instance Attribute Summary collapse
-
#legacy ⇒ Object
readonly
Returns the value of attribute legacy.
Instance Method Summary collapse
- #execute_async(transaction, priority: @priority) ⇒ Object
- #execute_sync(transaction, priority: @priority) ⇒ Object
-
#initialize(service_name:, priority: :normal, url: CDP_CORE_SERVICE_URL, secure: :this_channel_is_insecure, retries: 3) ⇒ Client
constructor
A new instance of Client.
- #method_missing(method_name, *_args) ⇒ Object
- #search(request:) ⇒ Object
Methods included from Retryable
Constructor Details
#initialize(service_name:, priority: :normal, url: CDP_CORE_SERVICE_URL, secure: :this_channel_is_insecure, retries: 3) ⇒ Client
Returns a new instance of Client.
12 13 14 15 16 17 18 19 20 |
# File 'lib/cdp/client.rb', line 12 def initialize(service_name:, priority: :normal, url: CDP_CORE_SERVICE_URL, secure: :this_channel_is_insecure, retries: 3) validate_priorities(priority) @service_name = service_name @priority = priority @retries = retries @service = CDP::Service::Stub.new(url, secure) @search_service = CDP::SearchService::Stub.new(url, secure) @legacy = CDP::Legacy::Service::Stub.new(url, secure) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
Instance Attribute Details
#legacy ⇒ Object (readonly)
Returns the value of attribute legacy.
8 9 10 |
# File 'lib/cdp/client.rb', line 8 def legacy @legacy end |
Instance Method Details
#execute_async(transaction, priority: @priority) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/cdp/client.rb', line 30 def execute_async(transaction, priority: @priority) validate_priorities(priority) response = retry_block(limit: @retries) { @service.execute_async(transaction, (priority: priority)) } response end |
#execute_sync(transaction, priority: @priority) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/cdp/client.rb', line 22 def execute_sync(transaction, priority: @priority) validate_priorities(priority) response = retry_block(limit: @retries) { @service.execute_sync(transaction, (priority: priority)) } response end |
#search(request:) ⇒ Object
38 39 40 41 42 |
# File 'lib/cdp/client.rb', line 38 def search(request:) retry_block(limit: @retries) { @search_service.execute(request) } end |