diff --git a/.gitmodules b/.gitmodules index 858d03871..897312433 100644 --- a/.gitmodules +++ b/.gitmodules @@ -157,3 +157,6 @@ [submodule "gems/http/5.1/_src"] path = gems/http/5.1/_src url = https://github.com/httprb/http.git +[submodule "gems/connection_pool/2.4/_src"] + path = gems/connection_pool/2.4/_src + url = https://github.com/mperham/connection_pool.git diff --git a/Gemfile.lock b/Gemfile.lock index 9750f07a0..69b79635f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -19,7 +19,7 @@ GEM rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) logger (1.5.3) - minitest (5.18.1) + minitest (5.19.0) parser (3.2.2.3) ast (~> 2.4.1) racc @@ -29,9 +29,9 @@ GEM rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) - rbs (3.1.1) + rbs (3.1.3) securerandom (0.2.2) - steep (1.5.1) + steep (1.5.2) activesupport (>= 5.1) concurrent-ruby (>= 1.1.10) csv (>= 3.0.9) diff --git a/gems/activesupport/7.0/activesupport-7.0.rbs b/gems/activesupport/7.0/activesupport-7.0.rbs index 66521a8b5..ef940b543 100644 --- a/gems/activesupport/7.0/activesupport-7.0.rbs +++ b/gems/activesupport/7.0/activesupport-7.0.rbs @@ -10,4 +10,42 @@ module ActiveSupport end end end + + module Notifications + interface _Callable5 + def call: (String, Time, Time, String, Hash[untyped, untyped]) -> void + end + + interface _Callable1 + def call: (untyped event) -> void + end + + # Subscribe to a given event name with the passed +block+. + # + # You can subscribe to events by passing a String to match exact event + # names, or by passing a Regexp to match all events that match a pattern. + # + # ActiveSupport::Notifications.subscribe(/render/) do |*args| + # @event = ActiveSupport::Notifications::Event.new(*args) + # end + # + # The +block+ will receive five parameters with information about the event: + # + # ActiveSupport::Notifications.subscribe('render') do |name, start, finish, id, payload| + # name # => String, name of the event (such as 'render' from above) + # start # => Time, when the instrumented block started execution + # finish # => Time, when the instrumented block ended execution + # id # => String, unique ID for the instrumenter that fired the event + # payload # => Hash, the payload + # end + # + # If the block passed to the method only takes one parameter, + # it will yield an event object to the block: + # + # ActiveSupport::Notifications.subscribe(/render/) do |event| + # @event = event + # end + def self.subscribe: (String | Regexp, _Callable5 | _Callable1) -> Subscriber + | ... + end end diff --git a/gems/connection_pool/2.4/_scripts/test b/gems/connection_pool/2.4/_scripts/test new file mode 100755 index 000000000..f2e713fe0 --- /dev/null +++ b/gems/connection_pool/2.4/_scripts/test @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# Exit command with non-zero status code, Output logs of every command executed, Treat unset variables as an error when substituting. +set -eou pipefail +# Internal Field Separator - Linux shell variable +IFS=$'\n\t' +# Print shell input lines +set -v + +# Set RBS_DIR variable to change directory to execute type checks using `steep check` +RBS_DIR=$(cd $(dirname $0)/..; pwd) +# Set REPO_DIR variable to validate RBS files added to the corresponding folder +REPO_DIR=$(cd $(dirname $0)/../../..; pwd) +# Validate RBS files, using the bundler environment present +bundle exec rbs --repo $REPO_DIR -r connection_pool:2.4 -r timeout validate --silent + +cd ${RBS_DIR}/_test +# Run type checks +bundle exec steep check + +$(git rev-parse --show-toplevel)/bin/check-untyped-call.rb diff --git a/gems/connection_pool/2.4/_src b/gems/connection_pool/2.4/_src new file mode 160000 index 000000000..f83b6304c --- /dev/null +++ b/gems/connection_pool/2.4/_src @@ -0,0 +1 @@ +Subproject commit f83b6304c0e5936b1b286b26a73f3febda051c9b diff --git a/gems/connection_pool/2.4/_test/Steepfile b/gems/connection_pool/2.4/_test/Steepfile new file mode 100644 index 000000000..1e9f11214 --- /dev/null +++ b/gems/connection_pool/2.4/_test/Steepfile @@ -0,0 +1,12 @@ +D = Steep::Diagnostic + +target :test do + check "." + signature "." + + repo_path "../../../" + library "connection_pool" + library "timeout" + + configure_code_diagnostics(D::Ruby.all_error) +end diff --git a/gems/connection_pool/2.4/_test/test.rb b/gems/connection_pool/2.4/_test/test.rb new file mode 100644 index 000000000..c0990f37e --- /dev/null +++ b/gems/connection_pool/2.4/_test/test.rb @@ -0,0 +1,16 @@ +# Write Ruby code to test the RBS. +# It is type checked by `steep check` command. + +require "connection_pool" + +pool = ConnectionPool.new(size: 5, timeout: 5) { Hash.new } + +pool.with do |h| + h['some-count'] +end + +pool.then { |h| h['some-count'] } + +pool.with(timeout: 2.0) do |h| + h['some-count'] +end diff --git a/gems/connection_pool/2.4/connection_pool.rbs b/gems/connection_pool/2.4/connection_pool.rbs new file mode 100644 index 000000000..1e3c71c67 --- /dev/null +++ b/gems/connection_pool/2.4/connection_pool.rbs @@ -0,0 +1,34 @@ +class ConnectionPool[T] + class Error < ::RuntimeError + end + + class PoolShuttingDownError < ::ConnectionPool::Error + end + + class TimeoutError < ::Timeout::Error + end + + class Wrapper[T] + def initialize: (pool: ConnectionPool[T]) -> void + | (?size: Integer, ?timeout: Numeric, ?auto_reload_after_fork: bool) { () -> T } -> void + def wrapped_pool: () -> ConnectionPool[T] + def with: () { (T) -> void } -> void + def pool_shutdown: () { (T) -> void } -> void + def pool_size: () -> Integer + def pool_available: () -> Integer + end + + def initialize: (?size: Integer, ?timeout: Numeric, ?auto_reload_after_fork: bool) { () -> T } -> void + def with: (?timeout: Numeric) { (T) -> void } -> void + def checkout: (?timeout: Numeric) -> T + def checkin: (?force: bool) -> void + def shutdown: () { (T) -> void } -> void + def reload: () { (T) -> void } -> void + + attr_reader size: Integer + attr_reader auto_reload_after_fork: bool + + def available: () -> Integer + + alias then with +end diff --git a/gems/connection_pool/2.4/manifest.yaml b/gems/connection_pool/2.4/manifest.yaml new file mode 100644 index 000000000..76f5f2209 --- /dev/null +++ b/gems/connection_pool/2.4/manifest.yaml @@ -0,0 +1,2 @@ +dependencies: + - name: timeout diff --git a/gems/rack/2.2/rack.rbs b/gems/rack/2.2/rack.rbs index c03205b50..9a4e12420 100644 --- a/gems/rack/2.2/rack.rbs +++ b/gems/rack/2.2/rack.rbs @@ -381,6 +381,7 @@ module Rack def respond_to_missing?: (untyped method_name, ?false include_all) -> bool def close: -> nil def closed?: -> bool + def each: () { (String) -> void } -> void def method_missing: (:each method_name, *untyped args) ?{ -> (IO | StringIO) } -> untyped end diff --git a/gems/redis/4.2/errors.rbs b/gems/redis/4.2/errors.rbs new file mode 100644 index 000000000..d05fb6707 --- /dev/null +++ b/gems/redis/4.2/errors.rbs @@ -0,0 +1,7 @@ +class Redis + class BaseError < StandardError + end + + class CommandError < BaseError + end +end diff --git a/gems/redis/4.2/redis.rbs b/gems/redis/4.2/redis.rbs index 892785c40..b991e54f4 100644 --- a/gems/redis/4.2/redis.rbs +++ b/gems/redis/4.2/redis.rbs @@ -159,7 +159,7 @@ class Redis def pipelined: () { (self & _Pipelined) -> void } -> Array[String | Integer] - # Mark the start of a transaction block. + # Mark the start of a transaction block. # # Passing a block is optional. # @@ -203,4 +203,65 @@ class Redis | (_ToS key, *untyped args, ?xx: bool, ?ch: bool, ?incr: bool) -> (bool | Integer | Float) def zincrby: (_ToS key, Integer|Float|"-inf"|"+inf" increment, String member) -> Float def zrem: (_ToS key, String|Array[String] member) -> (bool | Integer) + + # Disconnect the client as quickly and silently as possible. + def close: () -> void + + alias disconnect! close + + # Set a key's time to live in seconds. + # + # @param [String] key + # @param [Integer] seconds time to live + # @return [Boolean] whether the timeout was set or not + def expire: (String key, Integer seconds) -> bool + + # Evaluate Lua script by its SHA. + # + # @example EVALSHA without KEYS nor ARGV + # redis.evalsha(sha) + # # => + # @example EVALSHA with KEYS and ARGV as array arguments + # redis.evalsha(sha, ["k1", "k2"], ["a1", "a2"]) + # # => + # @example EVALSHA with KEYS and ARGV in a hash argument + # redis.evalsha(sha, :keys => ["k1", "k2"], :argv => ["a1", "a2"]) + # # => + # + # @param [Array] keys optional array with keys to pass to the script + # @param [Array] argv optional array with arguments to pass to the script + # @param [Hash] options + # - `:keys => Array`: optional array with keys to pass to the script + # - `:argv => Array`: optional array with arguments to pass to the script + # @return depends on the script + # + # @see #script + # @see #eval + def evalsha: (String, ?Array[String], ?Array[String], ?keys: Array[String], ?argv: Array[String]) -> untyped + + # Control remote script registry. + # + # @example Load a script + # sha = redis.script(:load, "return 1") + # # => + # @example Check if a script exists + # redis.script(:exists, sha) + # # => true + # @example Check if multiple scripts exist + # redis.script(:exists, [sha, other_sha]) + # # => [true, false] + # @example Flush the script registry + # redis.script(:flush) + # # => "OK" + # @example Kill a running script + # redis.script(:kill) + # # => "OK" + # + # @param [String] subcommand e.g. `exists`, `flush`, `load`, `kill` + # @param [Array] args depends on subcommand + # @return [String, Boolean, Array, ...] depends on subcommand + # + # @see #eval + # @see #evalsha + def script: (Symbol, *untyped) -> untyped end