Skip to content

Commit

Permalink
Merge branch 'ruby:main' into fix-sidekiq
Browse files Browse the repository at this point in the history
  • Loading branch information
soutaro authored Aug 3, 2023
2 parents 785f342 + ccbe167 commit 3f2ed35
Show file tree
Hide file tree
Showing 12 changed files with 200 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
38 changes: 38 additions & 0 deletions gems/activesupport/7.0/activesupport-7.0.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 21 additions & 0 deletions gems/connection_pool/2.4/_scripts/test
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions gems/connection_pool/2.4/_src
Submodule _src added at f83b63
12 changes: 12 additions & 0 deletions gems/connection_pool/2.4/_test/Steepfile
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions gems/connection_pool/2.4/_test/test.rb
Original file line number Diff line number Diff line change
@@ -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
34 changes: 34 additions & 0 deletions gems/connection_pool/2.4/connection_pool.rbs
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions gems/connection_pool/2.4/manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dependencies:
- name: timeout
1 change: 1 addition & 0 deletions gems/rack/2.2/rack.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions gems/redis/4.2/errors.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Redis
class BaseError < StandardError
end

class CommandError < BaseError
end
end
63 changes: 62 additions & 1 deletion gems/redis/4.2/redis.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand Down Expand Up @@ -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)
# # => <depends on script>
# @example EVALSHA with KEYS and ARGV as array arguments
# redis.evalsha(sha, ["k1", "k2"], ["a1", "a2"])
# # => <depends on script>
# @example EVALSHA with KEYS and ARGV in a hash argument
# redis.evalsha(sha, :keys => ["k1", "k2"], :argv => ["a1", "a2"])
# # => <depends on script>
#
# @param [Array<String>] keys optional array with keys to pass to the script
# @param [Array<String>] argv optional array with arguments to pass to the script
# @param [Hash] options
# - `:keys => Array<String>`: optional array with keys to pass to the script
# - `:argv => Array<String>`: 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")
# # => <sha of this script>
# @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<String>] args depends on subcommand
# @return [String, Boolean, Array<Boolean>, ...] depends on subcommand
#
# @see #eval
# @see #evalsha
def script: (Symbol, *untyped) -> untyped
end

0 comments on commit 3f2ed35

Please sign in to comment.