-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #505 from pocke/follow-502
Follow updating test script (#502)
- Loading branch information
Showing
33 changed files
with
1,002 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Write Ruby code to test the RBS. | ||
# It is type checked by `steep check` command. | ||
|
||
require "actioncable" |
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,11 @@ | ||
module ActionCable | ||
module Connection | ||
class Base | ||
end | ||
end | ||
|
||
module Channel | ||
class Base | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Write Ruby code to test the RBS. | ||
# It is type checked by `steep check` command. | ||
|
||
require "octokit" | ||
|
||
# Provide authentication credentials | ||
client = Octokit::Client.new(:access_token => 'personal_access_token') | ||
|
||
# You can still use the username/password syntax by replacing the password value with your PAT. | ||
# client = Octokit::Client.new(:login => 'defunkt', :password => 'personal_access_token') | ||
|
||
# Fetch the current user | ||
client.user |
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,27 @@ | ||
module Octokit | ||
class Client | ||
module Apps | ||
def create_app_installation_access_token: (Integer installation, **untyped) -> untyped | ||
def find_organization_installation: (String organization, **untyped) -> untyped | ||
end | ||
|
||
module Organizations | ||
def organization_member?: (String | Integer org, String user, **untyped options) -> bool | ||
end | ||
|
||
module Users | ||
def user: (?(Integer | String) user, ?Hash[untyped, untyped] options) -> untyped | ||
end | ||
|
||
include Apps | ||
include Organizations | ||
include Users | ||
|
||
def initialize: (?access_token: untyped, ?api_endpoint: untyped, ?auto_paginate: untyped, ?bearer_token: untyped, ?client_id: untyped, ?client_secret: untyped, ?connection_options: untyped, ?default_media_type: untyped, ?login: untyped, ?management_console_endpoint: untyped, ?management_console_password: untyped, ?middleware: untyped, ?netrc: untyped, ?netrc_file: untyped, ?per_page: untyped, ?password: untyped, ?proxy: untyped, ?ssl_verify_mode: untyped, ?user_agent: untyped, ?web_endpoint: untyped) -> void | ||
end | ||
|
||
class Error < StandardError | ||
end | ||
|
||
def self.user: (Integer) -> untyped | ||
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,21 @@ | ||
# Test fundamental APIs | ||
# Taken from: https://github.com/mperham/sidekiq/wiki/Getting-Started | ||
class HardWorker | ||
include Sidekiq::Job | ||
|
||
def perform(name, count) | ||
puts "Performing #{name} #{count} times" | ||
end | ||
end | ||
HardWorker.perform_async('bob', 5) | ||
HardWorker.perform_at(Time.now + 5*60, 'bob', 5) | ||
|
||
class HardJob | ||
include Sidekiq::Job | ||
|
||
def perform(name, count) | ||
puts "Performing #{name} #{count} times" | ||
end | ||
end | ||
HardJob.perform_async('bob', 5) | ||
HardJob.perform_at(Time.now + 5*60, 'bob', 5) |
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,15 @@ | ||
class HardWorker | ||
include Sidekiq::Job | ||
extend Sidekiq::Job::ClassMethods | ||
end | ||
|
||
class HardJob | ||
include Sidekiq::Job | ||
extend Sidekiq::Job::ClassMethods | ||
end | ||
|
||
class Hook | ||
end | ||
|
||
class Middleware | ||
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,70 @@ | ||
class HardWorker | ||
include Sidekiq::Job | ||
end | ||
|
||
class HardJob | ||
include Sidekiq::Job | ||
end | ||
|
||
class Hook | ||
end | ||
|
||
class Middleware | ||
end | ||
|
||
HardWorker.perform_async(1, 2, 3) | ||
HardJob.perform_async(1, 2, 3) | ||
|
||
# Test Sidekiq::Client | ||
client = Sidekiq::Client.new | ||
client.middleware do |chain| | ||
chain.add Middleware | ||
end | ||
Sidekiq::Client.push('class' => HardWorker, 'args' => [1, 2, 3]) | ||
Sidekiq::Client.push_bulk('class' => HardWorker, 'args' => [[1, 2, 3], [4,5,6]]) | ||
Sidekiq::Client.enqueue(HardWorker, 'foo', 1, :bat => 'bar') | ||
Sidekiq::Client.enqueue_to(:queue_name, HardWorker, 'foo', 1, :bat => 'bar') | ||
Sidekiq::Client.enqueue_to_in(:queue_name, Time.now + 3 * 60, HardWorker, 'foo', 1, :bat => 'bar') | ||
Sidekiq::Client.enqueue_in(Time.now + 3 * 60, HardWorker, 'foo', 1, :bat => 'bar') | ||
|
||
Sidekiq::Client.push('class' => HardJob, 'args' => [1, 2, 3]) | ||
Sidekiq::Client.push_bulk('class' => HardJob, 'args' => [[1, 2, 3], [4,5,6]]) | ||
Sidekiq::Client.enqueue(HardJob, 'foo', 1, :bat => 'bar') | ||
Sidekiq::Client.enqueue_to(:queue_name, HardJob, 'foo', 1, :bat => 'bar') | ||
Sidekiq::Client.enqueue_to_in(:queue_name, Time.now + 3 * 60, HardJob, 'foo', 1, :bat => 'bar') | ||
Sidekiq::Client.enqueue_in(Time.now + 3 * 60, HardJob, 'foo', 1, :bat => 'bar') | ||
|
||
# Test configuration of middleware | ||
Sidekiq.configure_server do |config| | ||
config.redis = { namespace: 'rails', size: 2, url: 'redis://rails:6457/0' } | ||
config.server_middleware do |chain| | ||
chain.add Hook | ||
end | ||
config.client_middleware do |chain| | ||
chain.add Hook | ||
end | ||
end | ||
|
||
# Using Redis | ||
# Taken from: https://github.com/mperham/sidekiq/wiki/Using-Redis | ||
Sidekiq.configure_server do |config| | ||
config.redis = { url: 'redis://redis.example.com:7372/0', network_timeout: 5 } | ||
end | ||
|
||
Sidekiq.configure_client do |config| | ||
config.redis = { url: 'redis://redis.example.com:7372/0' } | ||
end | ||
|
||
Sidekiq.configure_client do |config| | ||
config.redis = { url: 'redis://redis.example.com:7372/0', size: 5 } | ||
end | ||
|
||
Sidekiq.configure_server do |config| | ||
config.redis = { url: 'redis://redis.example.com:7372/0', size: 25 } | ||
end | ||
|
||
Sidekiq.configure_server do |config| | ||
config.on(:shutdown) do | ||
puts "Shutting down!" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
# Test error handling | ||
# Taken from: https://github.com/mperham/sidekiq/wiki/Error-Handling | ||
Sidekiq.configure_server do |config| | ||
config.error_handlers << proc { |ex,ctx_hash| puts "#{ex} exception: #{ctx_hash} context" } | ||
end | ||
|
||
class LessRetryableWorker | ||
include Sidekiq::Job | ||
sidekiq_options retry: 5 # Only five retries and then to the Dead Job Queue | ||
|
||
def perform | ||
end | ||
end | ||
|
||
class LessRetryableJob | ||
include Sidekiq::Job | ||
sidekiq_options retry: 5 # Only five retries and then to the Dead Job Queue | ||
|
||
def perform | ||
end | ||
end | ||
|
||
class NonRetryableWorker | ||
include Sidekiq::Job | ||
sidekiq_options retry: false # job will be discarded if it fails | ||
|
||
def perform | ||
end | ||
end | ||
|
||
class NonRetryableJob | ||
include Sidekiq::Job | ||
sidekiq_options retry: false # job will be discarded if it fails | ||
|
||
def perform | ||
end | ||
end | ||
|
||
class NoDeathWorker | ||
include Sidekiq::Job | ||
sidekiq_options retry: 5, dead: false # will retry 5 times and then disappear | ||
|
||
def perform | ||
end | ||
end | ||
|
||
class NoDeathJob | ||
include Sidekiq::Job | ||
sidekiq_options retry: 5, dead: false # will retry 5 times and then disappear | ||
|
||
def perform | ||
end | ||
end | ||
|
||
class WorkerWithCustomRetry | ||
include Sidekiq::Job | ||
sidekiq_options retry: 5 | ||
|
||
# The current retry count and exception is yielded. The return value of the | ||
# block must be an integer. It is used as the delay, in seconds. A return value | ||
# of nil will use the default. | ||
sidekiq_retry_in do |count, exception| | ||
case exception | ||
when Object | ||
10 * (count + 1) # (i.e. 10, 20, 30, 40, 50) | ||
end | ||
end | ||
|
||
def perform | ||
end | ||
end | ||
|
||
class JobWithCustomRetry | ||
include Sidekiq::Job | ||
sidekiq_options retry: 5 | ||
|
||
# The current retry count and exception is yielded. The return value of the | ||
# block must be an integer. It is used as the delay, in seconds. A return value | ||
# of nil will use the default. | ||
sidekiq_retry_in do |count, exception| | ||
case exception | ||
when Object | ||
10 * (count + 1) # (i.e. 10, 20, 30, 40, 50) | ||
end | ||
end | ||
|
||
def perform | ||
end | ||
end | ||
|
||
class FailingWorker | ||
include Sidekiq::Job | ||
|
||
sidekiq_retries_exhausted do |msg, ex| | ||
Sidekiq.logger.warn "Failed #{msg['class']} with #{msg['args']}: #{msg['error_message']}" | ||
end | ||
|
||
def perform | ||
raise "or I don't work" | ||
end | ||
end | ||
|
||
class FailingJob | ||
include Sidekiq::Job | ||
|
||
sidekiq_retries_exhausted do |msg, ex| | ||
Sidekiq.logger.warn "Failed #{msg['class']} with #{msg['args']}: #{msg['error_message']}" | ||
end | ||
|
||
def perform | ||
raise "or I don't work" | ||
end | ||
end | ||
|
||
# this goes in your initializer | ||
Sidekiq.configure_server do |config| | ||
config.death_handlers << -> (job, ex) do | ||
puts "Error!" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
class LessRetryableWorker | ||
include Sidekiq::Job | ||
extend Sidekiq::Job::ClassMethods | ||
def perform: () -> void | ||
end | ||
|
||
class LessRetryableJob | ||
include Sidekiq::Job | ||
extend Sidekiq::Job::ClassMethods | ||
def perform: () -> void | ||
end | ||
|
||
class NonRetryableWorker | ||
include Sidekiq::Job | ||
extend Sidekiq::Job::ClassMethods | ||
def perform: () -> void | ||
end | ||
|
||
class NonRetryableJob | ||
include Sidekiq::Job | ||
extend Sidekiq::Job::ClassMethods | ||
def perform: () -> void | ||
end | ||
|
||
class NoDeathWorker | ||
include Sidekiq::Job | ||
extend Sidekiq::Job::ClassMethods | ||
def perform: () -> void | ||
end | ||
|
||
class NoDeathJob | ||
include Sidekiq::Job | ||
extend Sidekiq::Job::ClassMethods | ||
def perform: () -> void | ||
end | ||
|
||
class WorkerWithCustomRetry | ||
include Sidekiq::Job | ||
extend Sidekiq::Job::ClassMethods | ||
extend Sidekiq::Job::Options::ClassMethods | ||
def perform: () -> void | ||
end | ||
|
||
class JobWithCustomRetry | ||
include Sidekiq::Job | ||
extend Sidekiq::Job::ClassMethods | ||
extend Sidekiq::Job::Options::ClassMethods | ||
def perform: () -> void | ||
end | ||
|
||
class FailingWorker | ||
include Sidekiq::Job | ||
extend Sidekiq::Job::ClassMethods | ||
extend Sidekiq::Job::Options::ClassMethods | ||
def perform: () -> void | ||
end | ||
|
||
class FailingJob | ||
include Sidekiq::Job | ||
extend Sidekiq::Job::ClassMethods | ||
extend Sidekiq::Job::Options::ClassMethods | ||
def perform: () -> void | ||
end | ||
|
||
class ImportantWorker | ||
include Sidekiq::Job | ||
extend Sidekiq::Job::ClassMethods | ||
def perform: () -> void | ||
end | ||
|
||
class ImportantJob | ||
include Sidekiq::Job | ||
extend Sidekiq::Job::ClassMethods | ||
def perform: () -> void | ||
end | ||
|
||
class YourWorker | ||
include Sidekiq::Job | ||
extend Sidekiq::Job::ClassMethods | ||
def perform: () -> void | ||
end | ||
|
||
class YourJob | ||
include Sidekiq::Job | ||
extend Sidekiq::Job::ClassMethods | ||
def perform: () -> void | ||
end |
Oops, something went wrong.