turbopuffer 2.10.0 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b2a36dd806fc7e21775b4a0edc355e2d22a0414bbf8e9069324514177f082031
4
- data.tar.gz: '099d6f2b73a34fe9485a2b36501cc26b4c9a74f4369f69d61b193b423b82e9d2'
3
+ metadata.gz: 2e9dcaf50f3956a7ab28076d62c9668e074ad220fa32776071a2531b9414a8eb
4
+ data.tar.gz: fb7352fbb282f96dd97b638a423c5d769559f547c278d154005435a84ebd87e5
5
5
  SHA512:
6
- metadata.gz: 3a2e126a3c4ae82652aebeaa7a58ecf06207780366faa8e913a598bcc49d8c6c8be90d47bfdb9059206ba03be5b8ed2425cca5004673b0914201d8e87ce9c317
7
- data.tar.gz: 584446333353eced6da9ebc066231a892d6ef5a40b58d5e5c4bb260b3b4da73a6e57fe33610af6d34bcee40365024f645df5fb1a6d5caaf9f33777b6bd006742
6
+ metadata.gz: 8c36f63bae627c2499bfe7571b5b03bbd1b641f6a198088f9746a58cbe9704cf32a9b9325d1f3f2799a98ff42a17107f6b2fdc278e05f98e1975d8f727a2cd90
7
+ data.tar.gz: 072f044dee012dc6035bb3b32696f7234d69448ccc6378e2dbc7b4ef2c3ea8217fc1b43bc3335c4a04a03dbe4880ec656d541c7ef7e31b9c6f7d7d32829bcec9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.11.0](https://github.com/turbopuffer/turbopuffer-ruby/compare/v2.10.0...v2.11.0) (2026-10-29)
4
+
5
+
6
+ ### Features
7
+
8
+ * Add a `max_connections` client option ([#82](https://github.com/turbopuffer/turbopuffer-ruby/issues/82)) ([d0d2f33](https://github.com/turbopuffer/turbopuffer-ruby/commit/d0d2f33d0a862152f68ada2fcfdf2a9e3b631593))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * stop requiring `base64`, which isn't a default gem as of Ruby 3.4 (thanks [@teoljungberg](https://github.com/teoljungberg)!) ([#81](https://github.com/turbopuffer/turbopuffer-ruby/issues/81)) ([c3380b6](https://github.com/turbopuffer/turbopuffer-ruby/commit/c3380b665fd1e3b5f400ac8ba816b136075c0683))
14
+
3
15
  ## [2.10.0](https://github.com/turbopuffer/turbopuffer-ruby/compare/v2.9.0...v2.10.0) (2026-10-29)
4
16
 
5
17
 
data/README.md CHANGED
@@ -17,7 +17,7 @@ To use this gem, install via Bundler by adding the following to your application
17
17
  <!-- x-release-please-start-version -->
18
18
 
19
19
  ```ruby
20
- gem "turbopuffer", "~> 2.10.0"
20
+ gem "turbopuffer", "~> 2.11.0"
21
21
  ```
22
22
 
23
23
  <!-- x-release-please-end -->
@@ -245,10 +245,18 @@ response = client.request(
245
245
 
246
246
  The `Turbopuffer::Client` instances are threadsafe, but are only are fork-safe when there are no in-flight HTTP requests.
247
247
 
248
- Each instance of `Turbopuffer::Client` has its own HTTP connection pool with a default size of 99. As such, we recommend instantiating the client once per application in most settings.
248
+ Each instance of `Turbopuffer::Client` has its own HTTP connection pool, which holds up to 99 connections to each origin by default (or one per processor, if there are more than 99). As such, we recommend instantiating the client once per application in most settings.
249
249
 
250
250
  When all available connections from the pool are checked out, requests wait for a new connection to become available, with queue time counting towards the request timeout.
251
251
 
252
+ You can use the `max_connections` option to configure the size of the pool:
253
+
254
+ ```ruby
255
+ turbopuffer = Turbopuffer::Client.new(
256
+ max_connections: 16 # default is 99, or the number of processors if greater
257
+ )
258
+ ```
259
+
252
260
  Unless otherwise specified, other classes in the SDK do not have locks protecting their underlying data structure.
253
261
 
254
262
  ## Sorbet
@@ -15,6 +15,9 @@ module Turbopuffer
15
15
  # Default max retry delay in seconds.
16
16
  DEFAULT_MAX_RETRY_DELAY = 8.0
17
17
 
18
+ # Default max number of concurrent HTTP connections to each origin.
19
+ DEFAULT_MAX_CONNECTIONS = Turbopuffer::Internal::Transport::PooledNetRequester::DEFAULT_MAX_CONNECTIONS
20
+
18
21
  # API key used for authentication.
19
22
  # @return [String]
20
23
  attr_reader :api_key
@@ -95,6 +98,10 @@ module Turbopuffer
95
98
  # @param initial_retry_delay [Float]
96
99
  #
97
100
  # @param max_retry_delay [Float]
101
+ #
102
+ # @param max_connections [Integer] Max number of concurrent HTTP connections to each origin. When all are in use,
103
+ # requests wait for one to become free, with the wait counting towards the request
104
+ # timeout.
98
105
  def initialize(
99
106
  api_key: ENV["TURBOPUFFER_API_KEY"],
100
107
  region: ENV["TURBOPUFFER_REGION"],
@@ -105,7 +112,8 @@ module Turbopuffer
105
112
  max_retries: self.class::DEFAULT_MAX_RETRIES,
106
113
  timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS,
107
114
  initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY,
108
- max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY
115
+ max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY,
116
+ max_connections: self.class::DEFAULT_MAX_CONNECTIONS
109
117
  )
110
118
  base_url ||= "https://{region}.turbopuffer.com"
111
119
 
@@ -145,6 +153,7 @@ module Turbopuffer
145
153
  max_retries: max_retries,
146
154
  initial_retry_delay: initial_retry_delay,
147
155
  max_retry_delay: max_retry_delay,
156
+ max_connections: max_connections,
148
157
  headers: headers
149
158
  )
150
159
 
@@ -168,6 +168,9 @@ module Turbopuffer
168
168
  # @return [Float]
169
169
  attr_reader :max_retry_delay
170
170
 
171
+ # @return [Integer]
172
+ attr_reader :max_connections
173
+
171
174
  # @return [Hash{String=>String}]
172
175
  attr_reader :headers
173
176
 
@@ -189,6 +192,7 @@ module Turbopuffer
189
192
  # @param max_retries [Integer]
190
193
  # @param initial_retry_delay [Float]
191
194
  # @param max_retry_delay [Float]
195
+ # @param max_connections [Integer]
192
196
  # @param headers [Hash{String=>String, Integer, Array<String, Integer, nil>, nil}]
193
197
  # @param idempotency_header [String, nil]
194
198
  def initialize(
@@ -197,10 +201,16 @@ module Turbopuffer
197
201
  max_retries: 0,
198
202
  initial_retry_delay: 0.0,
199
203
  max_retry_delay: 0.0,
204
+ max_connections: Turbopuffer::Internal::Transport::PooledNetRequester::DEFAULT_MAX_CONNECTIONS,
200
205
  headers: {},
201
206
  idempotency_header: nil
202
207
  )
203
- @requester = Turbopuffer::Internal::Transport::PooledNetRequester.new
208
+ # A pool of size zero would make every request wait out its timeout, so fail fast instead.
209
+ unless max_connections.is_a?(Integer) && max_connections.positive?
210
+ raise ArgumentError.new("max_connections must be a positive integer, got #{max_connections.inspect}")
211
+ end
212
+
213
+ @requester = Turbopuffer::Internal::Transport::PooledNetRequester.new(size: max_connections)
204
214
  @headers = Turbopuffer::Internal::Util.normalized_headers(
205
215
  self.class::PLATFORM_HEADERS,
206
216
  {
@@ -217,6 +227,7 @@ module Turbopuffer
217
227
  @max_retries = max_retries
218
228
  @initial_retry_delay = initial_retry_delay
219
229
  @max_retry_delay = max_retry_delay
230
+ @max_connections = max_connections
220
231
  @request_observer = nil
221
232
  end
222
233
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Turbopuffer
4
- VERSION = "2.10.0"
4
+ VERSION = "2.11.0"
5
5
  end
data/lib/turbopuffer.rb CHANGED
@@ -3,7 +3,6 @@
3
3
  # Standard libraries.
4
4
  # rubocop:disable Lint/RedundantRequireStatement
5
5
  require "English"
6
- require "base64"
7
6
  require "cgi"
8
7
  require "date"
9
8
  require "erb"
data/manifest.yaml CHANGED
@@ -1,6 +1,5 @@
1
1
  dependencies:
2
2
  - English
3
- - base64
4
3
  - cgi
5
4
  - date
6
5
  - erb
@@ -10,6 +10,8 @@ module Turbopuffer
10
10
 
11
11
  DEFAULT_MAX_RETRY_DELAY = T.let(8.0, Float)
12
12
 
13
+ DEFAULT_MAX_CONNECTIONS = T.let(T.unsafe(nil), Integer)
14
+
13
15
  # API key used for authentication.
14
16
  sig { returns(String) }
15
17
  attr_reader :api_key
@@ -70,7 +72,8 @@ module Turbopuffer
70
72
  max_retries: Integer,
71
73
  timeout: Float,
72
74
  initial_retry_delay: Float,
73
- max_retry_delay: Float
75
+ max_retry_delay: Float,
76
+ max_connections: Integer
74
77
  ).returns(T.attached_class)
75
78
  end
76
79
  def self.new(
@@ -92,7 +95,11 @@ module Turbopuffer
92
95
  max_retries: Turbopuffer::Client::DEFAULT_MAX_RETRIES,
93
96
  timeout: Turbopuffer::Client::DEFAULT_TIMEOUT_IN_SECONDS,
94
97
  initial_retry_delay: Turbopuffer::Client::DEFAULT_INITIAL_RETRY_DELAY,
95
- max_retry_delay: Turbopuffer::Client::DEFAULT_MAX_RETRY_DELAY
98
+ max_retry_delay: Turbopuffer::Client::DEFAULT_MAX_RETRY_DELAY,
99
+ # Max number of concurrent HTTP connections to each origin. When all are in use,
100
+ # requests wait for one to become free, with the wait counting towards the request
101
+ # timeout.
102
+ max_connections: Turbopuffer::Client::DEFAULT_MAX_CONNECTIONS
96
103
  )
97
104
  end
98
105
  end
@@ -132,6 +132,9 @@ module Turbopuffer
132
132
  sig { returns(Float) }
133
133
  attr_reader :max_retry_delay
134
134
 
135
+ sig { returns(Integer) }
136
+ attr_reader :max_connections
137
+
135
138
  sig { returns(T::Hash[String, String]) }
136
139
  attr_reader :headers
137
140
 
@@ -156,6 +159,7 @@ module Turbopuffer
156
159
  max_retries: Integer,
157
160
  initial_retry_delay: Float,
158
161
  max_retry_delay: Float,
162
+ max_connections: Integer,
159
163
  headers:
160
164
  T::Hash[
161
165
  String,
@@ -176,6 +180,7 @@ module Turbopuffer
176
180
  max_retries: 0,
177
181
  initial_retry_delay: 0.0,
178
182
  max_retry_delay: 0.0,
183
+ max_connections: Turbopuffer::Internal::Transport::PooledNetRequester::DEFAULT_MAX_CONNECTIONS,
179
184
  headers: {},
180
185
  idempotency_header: nil
181
186
  )
@@ -8,6 +8,8 @@ module Turbopuffer
8
8
 
9
9
  DEFAULT_MAX_RETRY_DELAY: Float
10
10
 
11
+ DEFAULT_MAX_CONNECTIONS: Integer
12
+
11
13
  attr_reader api_key: String
12
14
 
13
15
  attr_reader region: String?
@@ -37,7 +39,8 @@ module Turbopuffer
37
39
  ?max_retries: Integer,
38
40
  ?timeout: Float,
39
41
  ?initial_retry_delay: Float,
40
- ?max_retry_delay: Float
42
+ ?max_retry_delay: Float,
43
+ ?max_connections: Integer
41
44
  ) -> void
42
45
  end
43
46
  end
@@ -66,6 +66,8 @@ module Turbopuffer
66
66
 
67
67
  attr_reader max_retry_delay: Float
68
68
 
69
+ attr_reader max_connections: Integer
70
+
69
71
  attr_reader headers: ::Hash[String, String]
70
72
 
71
73
  attr_reader idempotency_header: String?
@@ -82,6 +84,7 @@ module Turbopuffer
82
84
  ?max_retries: Integer,
83
85
  ?initial_retry_delay: Float,
84
86
  ?max_retry_delay: Float,
87
+ ?max_connections: Integer,
85
88
  ?headers: ::Hash[String, (String
86
89
  | Integer
87
90
  | ::Array[(String | Integer)?])?],
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbopuffer
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.10.0
4
+ version: 2.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Turbopuffer