redis-promise 0.1.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.
Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/ci.yml +74 -0
  3. data/CHANGELOG.md +19 -0
  4. data/LICENSE +21 -0
  5. data/README.md +151 -0
  6. data/Rakefile +12 -0
  7. data/lib/redis/promise/resolver.rb +47 -0
  8. data/lib/redis/promise/resque.rb +49 -0
  9. data/lib/redis/promise/version.rb +8 -0
  10. data/lib/redis/promise.rb +83 -0
  11. data/sorbet/config +7 -0
  12. data/sorbet/rbi/annotations/.gitattributes +1 -0
  13. data/sorbet/rbi/annotations/minitest.rbi +120 -0
  14. data/sorbet/rbi/annotations/rainbow.rbi +269 -0
  15. data/sorbet/rbi/gems/.gitattributes +1 -0
  16. data/sorbet/rbi/gems/ast@2.4.3.rbi +586 -0
  17. data/sorbet/rbi/gems/byebug@13.0.0.rbi +37 -0
  18. data/sorbet/rbi/gems/connection_pool@3.0.2.rbi +340 -0
  19. data/sorbet/rbi/gems/date@3.5.1.rbi +403 -0
  20. data/sorbet/rbi/gems/erb@6.0.4.rbi +814 -0
  21. data/sorbet/rbi/gems/io-console@0.8.2.rbi +9 -0
  22. data/sorbet/rbi/gems/json@2.19.5.rbi +2250 -0
  23. data/sorbet/rbi/gems/lint_roller@1.1.0.rbi +323 -0
  24. data/sorbet/rbi/gems/minitest@5.27.0.rbi +1549 -0
  25. data/sorbet/rbi/gems/parallel@2.1.0.rbi +359 -0
  26. data/sorbet/rbi/gems/pp@0.6.3.rbi +388 -0
  27. data/sorbet/rbi/gems/prettyprint@0.2.0.rbi +477 -0
  28. data/sorbet/rbi/gems/psych@5.3.1.rbi +2555 -0
  29. data/sorbet/rbi/gems/racc@1.8.1.rbi +168 -0
  30. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +403 -0
  31. data/sorbet/rbi/gems/rake@13.4.2.rbi +3258 -0
  32. data/sorbet/rbi/gems/redis-client@0.29.0.rbi +1203 -0
  33. data/sorbet/rbi/gems/redis@5.4.1.rbi +3552 -0
  34. data/sorbet/rbi/gems/reline@0.6.3.rbi +2995 -0
  35. data/sorbet/rbi/gems/rubocop-espago@1.2.0.rbi +9 -0
  36. data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +1318 -0
  37. data/sorbet/rbi/gems/shoulda-context@2.0.0.rbi +563 -0
  38. data/sorbet/rbi/gems/stringio@3.2.0.rbi +9 -0
  39. data/sorbet/rbi/gems/tsort@0.2.0.rbi +393 -0
  40. data/sorbet/rbi/gems/unicode-display_width@3.2.0.rbi +132 -0
  41. data/sorbet/rbi/gems/unicode-emoji@4.2.0.rbi +254 -0
  42. data/sorbet/rbi/shims/gems/resque.rbi +9 -0
  43. data/sorbet/rbi/shims/gems/shoulda-context.rbi +16 -0
  44. data/sorbet/rbi/todo.rbi +5 -0
  45. data/sorbet/tapioca/config.yml +31 -0
  46. data/sorbet/tapioca/extensions/load_gem.rb +1 -0
  47. data/sorbet/tapioca/require.rb +5 -0
  48. metadata +117 -0
@@ -0,0 +1,340 @@
1
+ # typed: true
2
+
3
+ # DO NOT EDIT MANUALLY
4
+ # This is an autogenerated file for types exported from the `connection_pool` gem.
5
+ # Please instead update this file by running `bin/tapioca gem connection_pool`.
6
+
7
+
8
+ # Generic connection pool class for sharing a limited number of objects or network connections
9
+ # among many threads. Note: pool elements are lazily created.
10
+ #
11
+ # Example usage with block (faster):
12
+ #
13
+ # @pool = ConnectionPool.new { Redis.new }
14
+ # @pool.with do |redis|
15
+ # redis.lpop('my-list') if redis.llen('my-list') > 0
16
+ # end
17
+ #
18
+ # Using optional timeout override (for that single invocation)
19
+ #
20
+ # @pool.with(timeout: 2.0) do |redis|
21
+ # redis.lpop('my-list') if redis.llen('my-list') > 0
22
+ # end
23
+ #
24
+ # Example usage replacing an existing connection (slower):
25
+ #
26
+ # $redis = ConnectionPool.wrap { Redis.new }
27
+ #
28
+ # def do_work
29
+ # $redis.lpop('my-list') if $redis.llen('my-list') > 0
30
+ # end
31
+ #
32
+ # Accepts the following options:
33
+ # - :size - number of connections to pool, defaults to 5
34
+ # - :timeout - amount of time to wait for a connection if none currently available, defaults to 5 seconds
35
+ # - :auto_reload_after_fork - automatically drop all connections after fork, defaults to true
36
+ #
37
+ # pkg:gem/connection_pool#lib/connection_pool/version.rb:1
38
+ class ConnectionPool
39
+ # pkg:gem/connection_pool#lib/connection_pool.rb:48
40
+ def initialize(timeout: T.unsafe(nil), size: T.unsafe(nil), auto_reload_after_fork: T.unsafe(nil), name: T.unsafe(nil), &_arg4); end
41
+
42
+ # Number of pool entries available for checkout at this instant.
43
+ #
44
+ # pkg:gem/connection_pool#lib/connection_pool.rb:173
45
+ def available; end
46
+
47
+ # pkg:gem/connection_pool#lib/connection_pool.rb:123
48
+ def checkin(force: T.unsafe(nil)); end
49
+
50
+ # pkg:gem/connection_pool#lib/connection_pool.rb:111
51
+ def checkout(timeout: T.unsafe(nil), **_arg1); end
52
+
53
+ # Marks the current thread's checked-out connection for discard.
54
+ #
55
+ # When a connection is marked for discard, it will not be returned to the pool
56
+ # when checked in. Instead, the connection will be discarded.
57
+ # This is useful when a connection has become invalid or corrupted
58
+ # and should not be reused.
59
+ #
60
+ # Takes an optional block that will be called with the connection to be discarded.
61
+ # The block should perform any necessary clean-up on the connection.
62
+ #
63
+ # @yield [conn]
64
+ # @yieldparam conn [Object] The connection to be discarded.
65
+ # @yieldreturn [void]
66
+ #
67
+ #
68
+ # Note: This only affects the connection currently checked out by the calling thread.
69
+ # The connection will be discarded when +checkin+ is called.
70
+ #
71
+ # @return [void]
72
+ #
73
+ # @example
74
+ # pool.with do |conn|
75
+ # begin
76
+ # conn.execute("SELECT 1")
77
+ # rescue SomeConnectionError
78
+ # pool.discard_current_connection # Mark connection as bad
79
+ # raise
80
+ # end
81
+ # end
82
+ #
83
+ # pkg:gem/connection_pool#lib/connection_pool.rb:107
84
+ def discard_current_connection(&block); end
85
+
86
+ # Number of pool entries created and idle in the pool.
87
+ #
88
+ # pkg:gem/connection_pool#lib/connection_pool.rb:178
89
+ def idle; end
90
+
91
+ # Reaps idle connections that have been idle for over +idle_seconds+.
92
+ # +idle_seconds+ defaults to 60.
93
+ #
94
+ # pkg:gem/connection_pool#lib/connection_pool.rb:168
95
+ def reap(idle_seconds: T.unsafe(nil), &_arg1); end
96
+
97
+ # Reloads the ConnectionPool by passing each connection to +block+ and then
98
+ # removing it the pool. Subsequent checkouts will create new connections as
99
+ # needed.
100
+ #
101
+ # pkg:gem/connection_pool#lib/connection_pool.rb:162
102
+ def reload(&_arg0); end
103
+
104
+ # Shuts down the ConnectionPool by passing each connection to +block+ and
105
+ # then removing it from the pool. Attempting to checkout a connection after
106
+ # shutdown will raise +ConnectionPool::PoolShuttingDownError+.
107
+ #
108
+ # pkg:gem/connection_pool#lib/connection_pool.rb:154
109
+ def shutdown(&_arg0); end
110
+
111
+ # pkg:gem/connection_pool#lib/connection_pool.rb:46
112
+ def size; end
113
+
114
+ # pkg:gem/connection_pool#lib/connection_pool.rb:75
115
+ def then(**_arg0); end
116
+
117
+ # pkg:gem/connection_pool#lib/connection_pool.rb:60
118
+ def with(**_arg0); end
119
+
120
+ class << self
121
+ # pkg:gem/connection_pool#lib/connection_pool/fork.rb:6
122
+ def after_fork; end
123
+
124
+ # pkg:gem/connection_pool#lib/connection_pool.rb:42
125
+ def wrap(**_arg0, &_arg1); end
126
+ end
127
+ end
128
+
129
+ # pkg:gem/connection_pool#lib/connection_pool.rb:5
130
+ class ConnectionPool::Error < ::RuntimeError; end
131
+
132
+ # pkg:gem/connection_pool#lib/connection_pool/fork.rb:21
133
+ module ConnectionPool::ForkTracker
134
+ # pkg:gem/connection_pool#lib/connection_pool/fork.rb:22
135
+ def _fork; end
136
+ end
137
+
138
+ # JRuby, et al
139
+ #
140
+ # pkg:gem/connection_pool#lib/connection_pool/fork.rb:3
141
+ ConnectionPool::INSTANCES = T.let(T.unsafe(nil), ObjectSpace::WeakMap)
142
+
143
+ # pkg:gem/connection_pool#lib/connection_pool.rb:7
144
+ class ConnectionPool::PoolShuttingDownError < ::ConnectionPool::Error; end
145
+
146
+ # The TimedStack manages a pool of homogeneous connections (or any resource
147
+ # you wish to manage). Connections are created lazily up to a given maximum
148
+ # number.
149
+ #
150
+ # Examples:
151
+ #
152
+ # ts = TimedStack.new(size: 1) { MyConnection.new }
153
+ #
154
+ # # fetch a connection
155
+ # conn = ts.pop
156
+ #
157
+ # # return a connection
158
+ # ts.push conn
159
+ #
160
+ # conn = ts.pop
161
+ # ts.pop timeout: 5
162
+ # #=> raises ConnectionPool::TimeoutError after 5 seconds
163
+ #
164
+ # pkg:gem/connection_pool#lib/connection_pool/timed_stack.rb:19
165
+ class ConnectionPool::TimedStack
166
+ # Creates a new pool with +size+ connections that are created from the given
167
+ # +block+.
168
+ #
169
+ # pkg:gem/connection_pool#lib/connection_pool/timed_stack.rb:25
170
+ def initialize(size: T.unsafe(nil), &block); end
171
+
172
+ # pkg:gem/connection_pool#lib/connection_pool/timed_stack.rb:50
173
+ def <<(obj, **_arg1); end
174
+
175
+ # Reduce the created count
176
+ #
177
+ # pkg:gem/connection_pool#lib/connection_pool/timed_stack.rb:143
178
+ def decrement_created; end
179
+
180
+ # Returns +true+ if there are no available connections.
181
+ #
182
+ # pkg:gem/connection_pool#lib/connection_pool/timed_stack.rb:125
183
+ def empty?; end
184
+
185
+ # The number of connections created and available on the stack.
186
+ #
187
+ # pkg:gem/connection_pool#lib/connection_pool/timed_stack.rb:137
188
+ def idle; end
189
+
190
+ # The number of connections available on the stack.
191
+ #
192
+ # pkg:gem/connection_pool#lib/connection_pool/timed_stack.rb:131
193
+ def length; end
194
+
195
+ # pkg:gem/connection_pool#lib/connection_pool/timed_stack.rb:20
196
+ def max; end
197
+
198
+ # Retrieves a connection from the stack. If a connection is available it is
199
+ # immediately returned. If no connection is available within the given
200
+ # timeout a ConnectionPool::TimeoutError is raised.
201
+ #
202
+ # @option options [Float] :timeout (0.5) Wait this many seconds for an available entry
203
+ # @option options [Class] :exception (ConnectionPool::TimeoutError) Exception class to raise
204
+ # if an entry was not available within the timeout period. Use `exception: false` to return nil.
205
+ #
206
+ # Other options may be used by subclasses that extend TimedStack.
207
+ #
208
+ # pkg:gem/connection_pool#lib/connection_pool/timed_stack.rb:62
209
+ def pop(timeout: T.unsafe(nil), exception: T.unsafe(nil), **_arg2); end
210
+
211
+ # Returns +obj+ to the stack. Additional kwargs are ignored in TimedStack but may be
212
+ # used by subclasses that extend TimedStack.
213
+ #
214
+ # pkg:gem/connection_pool#lib/connection_pool/timed_stack.rb:38
215
+ def push(obj, **_arg1); end
216
+
217
+ # Reaps connections that were checked in more than +idle_seconds+ ago.
218
+ #
219
+ # pkg:gem/connection_pool#lib/connection_pool/timed_stack.rb:106
220
+ def reap(idle_seconds:); end
221
+
222
+ # Shuts down the TimedStack by passing each connection to +block+ and then
223
+ # removing it from the pool. Attempting to checkout a connection after
224
+ # shutdown will raise +ConnectionPool::PoolShuttingDownError+ unless
225
+ # +:reload+ is +true+.
226
+ #
227
+ # pkg:gem/connection_pool#lib/connection_pool/timed_stack.rb:92
228
+ def shutdown(reload: T.unsafe(nil), &block); end
229
+
230
+ private
231
+
232
+ # This is an extension point for TimedStack and is called with a mutex.
233
+ #
234
+ # This method must returns true if a connection is available on the stack.
235
+ #
236
+ # pkg:gem/connection_pool#lib/connection_pool/timed_stack.rb:167
237
+ def connection_stored?(**_arg0); end
238
+
239
+ # pkg:gem/connection_pool#lib/connection_pool/timed_stack.rb:149
240
+ def current_time; end
241
+
242
+ # This is an extension point for TimedStack and is called with a mutex.
243
+ #
244
+ # This method must return a connection from the stack.
245
+ #
246
+ # pkg:gem/connection_pool#lib/connection_pool/timed_stack.rb:175
247
+ def fetch_connection(**_arg0); end
248
+
249
+ # This is an extension point for TimedStack and is called with a mutex.
250
+ #
251
+ # Returns true if the first connection in the stack has been idle for more than idle_seconds
252
+ #
253
+ # pkg:gem/connection_pool#lib/connection_pool/timed_stack.rb:209
254
+ def idle_connections?(idle_seconds); end
255
+
256
+ # This is an extension point for TimedStack and is called with a mutex.
257
+ #
258
+ # This method returns the oldest idle connection if it has been idle for more than idle_seconds.
259
+ # This requires that the stack is kept in order of checked in time (oldest first).
260
+ #
261
+ # pkg:gem/connection_pool#lib/connection_pool/timed_stack.rb:195
262
+ def reserve_idle_connection(idle_seconds); end
263
+
264
+ # This is an extension point for TimedStack and is called with a mutex.
265
+ #
266
+ # This method must shut down all connections on the stack.
267
+ #
268
+ # pkg:gem/connection_pool#lib/connection_pool/timed_stack.rb:183
269
+ def shutdown_connections(**_arg0); end
270
+
271
+ # This is an extension point for TimedStack and is called with a mutex.
272
+ #
273
+ # This method must return +obj+ to the stack.
274
+ #
275
+ # pkg:gem/connection_pool#lib/connection_pool/timed_stack.rb:220
276
+ def store_connection(obj, **_arg1); end
277
+
278
+ # This is an extension point for TimedStack and is called with a mutex.
279
+ #
280
+ # This method must create a connection if and only if the total number of
281
+ # connections allowed has not been met.
282
+ #
283
+ # pkg:gem/connection_pool#lib/connection_pool/timed_stack.rb:229
284
+ def try_create(**_arg0); end
285
+
286
+ # This is an extension point for TimedStack and is called with a mutex.
287
+ #
288
+ # This method must returns a connection from the stack if one exists. Allows
289
+ # subclasses with expensive match/search algorithms to avoid double-handling
290
+ # their stack.
291
+ #
292
+ # pkg:gem/connection_pool#lib/connection_pool/timed_stack.rb:159
293
+ def try_fetch_connection(**_arg0); end
294
+ end
295
+
296
+ # pkg:gem/connection_pool#lib/connection_pool.rb:9
297
+ class ConnectionPool::TimeoutError < ::Timeout::Error; end
298
+
299
+ # pkg:gem/connection_pool#lib/connection_pool/version.rb:2
300
+ ConnectionPool::VERSION = T.let(T.unsafe(nil), String)
301
+
302
+ # pkg:gem/connection_pool#lib/connection_pool/wrapper.rb:2
303
+ class ConnectionPool::Wrapper < ::BasicObject
304
+ # pkg:gem/connection_pool#lib/connection_pool/wrapper.rb:5
305
+ def initialize(**options, &_arg1); end
306
+
307
+ # pkg:gem/connection_pool#lib/connection_pool/wrapper.rb:37
308
+ def method_missing(name, *_arg1, **_arg2, &_arg3); end
309
+
310
+ # pkg:gem/connection_pool#lib/connection_pool/wrapper.rb:25
311
+ def pool_available; end
312
+
313
+ # pkg:gem/connection_pool#lib/connection_pool/wrapper.rb:17
314
+ def pool_shutdown(&_arg0); end
315
+
316
+ # pkg:gem/connection_pool#lib/connection_pool/wrapper.rb:21
317
+ def pool_size; end
318
+
319
+ # pkg:gem/connection_pool#lib/connection_pool/wrapper.rb:29
320
+ def respond_to?(id, *_arg1, **_arg2); end
321
+
322
+ # pkg:gem/connection_pool#lib/connection_pool/wrapper.rb:13
323
+ def with(**_arg0, &_arg1); end
324
+
325
+ # pkg:gem/connection_pool#lib/connection_pool/wrapper.rb:9
326
+ def wrapped_pool; end
327
+
328
+ private
329
+
330
+ # pkg:gem/connection_pool#lib/connection_pool/wrapper.rb:33
331
+ def respond_to_missing?(id, *_arg1, **_arg2); end
332
+ end
333
+
334
+ # pkg:gem/connection_pool#lib/connection_pool/wrapper.rb:3
335
+ ConnectionPool::Wrapper::METHODS = T.let(T.unsafe(nil), Array)
336
+
337
+ module Process
338
+ extend ::RedisClient::PIDCache::CoreExt
339
+ extend ::ConnectionPool::ForkTracker
340
+ end