-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'ruby:main' into fix-sidekiq
- Loading branch information
Showing
12 changed files
with
200 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dependencies: | ||
- name: timeout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters