Skip to content

Commit

Permalink
Merge pull request #507 from pocke/follow-494
Browse files Browse the repository at this point in the history
Follow 494
  • Loading branch information
pocke authored Jan 25, 2024
2 parents c87dbef + 683d60d commit 9cf3ee1
Show file tree
Hide file tree
Showing 9 changed files with 188 additions and 20 deletions.
2 changes: 2 additions & 0 deletions gems/shoryuken/6.0/_test/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
additional_gems:
- aws-sdk-sqs
5 changes: 5 additions & 0 deletions gems/shoryuken/6.0/client.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Shoryuken
class Client
def self.queues: (String name) -> Queue
end
end
11 changes: 11 additions & 0 deletions gems/shoryuken/6.0/logging.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Shoryuken
module Logging
def self.initialize_logger: (?Logger::logdev? log_target) -> Logger

def self.logger: () -> Logger

def self.logger=: (Logger log) -> void

def self.with_context: (untyped msg) { () -> void } -> void
end
end
1 change: 1 addition & 0 deletions gems/shoryuken/6.0/manifest.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
dependencies:
- name: forwardable
- name: logger
39 changes: 39 additions & 0 deletions gems/shoryuken/6.0/middleware.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module Shoryuken
module Middleware
class Chain
attr_reader entries: Array[Entry]

def add: (singleton(Class) klass, *untyped args) -> void

def clear: () -> void

def exists?: (untyped klass) -> bool

def insert_after: (untyped oldklass, untyped newklass, *untyped args) -> void

def insert_before: (untyped oldklass, untyped newklass, *untyped args) -> void

def invoke: (*untyped args) { () -> void } -> void

def prepend: (untyped klass, *untyped args) -> void

def remove: (untyped klass) -> void

def retrieve: () -> Array[untyped]

private

def initialize: () ?{ (self) -> void } -> void

class Entry
attr_reader klass: singleton(Class)

@args: Array[untyped]

def initialize: (singleton(Class), *untyped args) -> void

def make_new: () -> untyped
end
end
end
end
68 changes: 68 additions & 0 deletions gems/shoryuken/6.0/options.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
module Shoryuken
class Options
type group = { concurrency: Integer, delay: Numeric, queues: Array[String] }

attr_accessor active_job_queue_name_prefixing: bool
attr_accessor cache_visibility_timeout: bool
attr_accessor groups: Hash[String, group]
attr_accessor exception_handlers: Array[untyped]
attr_accessor launcher_executor: untyped
attr_accessor worker_executor: untyped
attr_accessor worker_registry: untyped
attr_accessor start_callback: (^() -> void | nil)
attr_accessor stop_callback: (^() -> void | nil)
attr_writer default_worker_options: Hash[String, untyped]
attr_writer sqs_client: Aws::SQS::Client
attr_reader sqs_client_receive_message_opts: Hash[Symbol, untyped]

def active_job?: () -> boolish

def active_job_queue_name_prefixing?: () -> bool

def add_group: (String group, ?Integer concurrency, ?delay: Numeric) -> void

def add_queue: (String queue, Integer weight, String group) -> void

def cache_visibility_timeout?: () -> bool

def client_middleware: () ?{ (Middleware::Chain) -> void } -> Middleware::Chain

def configure_client: () { (self) -> void } -> void

def configure_server: () { (self) -> void } -> void

def delay: (String group) -> Numeric

def logger: () -> Logger

def on: (Symbol event) { () -> void } -> void

def on_start: () { () -> void } -> void

def on_stop: () { () -> void } -> void

def options: () -> Hash[Symbol, untyped]

def polling_strategy: (String group) -> untyped

def register_worker: (*untyped args) -> void

def server?: () -> bool

def server_middleware: () ?{ (Middleware::Chain) -> void } -> Middleware::Chain

def sqs_client: () -> Aws::SQS::Client

def ungrouped_queues: () -> Array[untyped]

private

def default_client_middleware: () -> Middleware::Chain

def default_server_middleware: () -> Middleware::Chain

def initialize: () -> void

DEFAULTS: ::Hash[Symbol, untyped]
end
end
10 changes: 10 additions & 0 deletions gems/shoryuken/6.0/queue.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Shoryuken
class Queue
def visibility_timeout: () -> Integer
def delete_messages: (untyped options) -> void
def send_message: (untyped options) -> void
def send_messages: (untyped options) -> void
def receive_messages: (untyped options) -> void
def fifo?: () -> bool
end
end
65 changes: 45 additions & 20 deletions gems/shoryuken/6.0/shoryuken.rbs
Original file line number Diff line number Diff line change
@@ -1,22 +1,47 @@
module Shoryuken
class Client
def self.queues: (String name) -> Queue
end

class Queue
def visibility_timeout: () -> Integer
def delete_messages: (untyped options) -> void
def send_message: (untyped options) -> void
def send_messages: (untyped options) -> void
def receive_messages: (untyped options) -> void
def fifo?: () -> bool
end

module Worker
module ClassMethods
def shoryuken_options: (?queue: String, ?delete: bool, ?auto_delete: bool, ?auto_visibility_timeout: bool, ?retry_intervals: Numeric, ?batch: bool) -> void
end
end

def self.logger: () -> Logger
extend SingleForwardable

def self?.shoryuken_options: () -> Options

def self?.healthy?: () -> bool

# would be great here to somehow annotate delegation...

def self?.active_job?: () -> boolish

def self?.add_group: (String group, ?Integer concurrency, ?delay: Numeric) -> void

def self?.add_queue: (String queue, Integer weight, String group) -> void

def self?.ungrouped_queues: () -> Array[untyped]

def self?.active_job_queue_name_prefixing?: () -> bool

def self?.sqs_client: () -> Aws::SQS::Client

def self?.options: () -> Hash[Symbol, untyped]

def self?.logger: () -> Logger

def self?.register_worker: (*untyped args) -> void

def self?.configure_server: () { (self) -> void } -> void

def self?.server?: () -> bool

def self?.server_middleware: () ?{ (Middleware::Chain) -> void } -> Middleware::Chain

def self?.configure_client: () { (self) -> void } -> void

def self?.client_middleware: () ?{ (Middleware::Chain) -> void } -> Middleware::Chain

def self?.on: (Symbol event) { () -> void } -> void

def self?.on_start: () { () -> void } -> void

def self?.on_stop: () { () -> void } -> void

def self?.delay: (String group) -> Numeric

VERSION: ::String
end
7 changes: 7 additions & 0 deletions gems/shoryuken/6.0/worker.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Shoryuken
module Worker
module ClassMethods
def shoryuken_options: (?queue: String, ?delete: bool, ?auto_delete: bool, ?auto_visibility_timeout: bool, ?retry_intervals: Numeric, ?batch: bool) -> void
end
end
end

0 comments on commit 9cf3ee1

Please sign in to comment.