Skip to main content

Adding Support for Persistent Connections in Ruby SDK

· One min read

Previously, our Ruby SDKs were initiating a new connection for each API call. Now, we have made this HTTP connection persistent. Using persistent request allows all server requests to be made through one connection, consequently reducing network latency.

Details

We now support persistent connections in Ruby SDK. To support persistent connection by default, we have changed the default adapter net_http to net_http_persistent. The details of this net_http_persistent adapter can be found here.

Here are the configuration changes that reflect HTTP connection calls.

Client

def initialize(connection: nil, adapter: :net_http_persistent, timeout: 60,
max_retries: 0, retry_interval: 1, backoff_factor: 2,
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
retry_methods: %i[get put],
environment: Environment::TESTING, port: '80',
suites: SuiteCode::HEARTS, config: nil)

Configuration

def initialize(connection: nil, adapter: :net_http_persistent, timeout: 60,
max_retries: 0, retry_interval: 1, backoff_factor: 2,
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
retry_methods: %i[get put],
environment: Environment::TESTING, port: '80',
suites: SuiteCode::HEARTS)