class Ractored < Generic
- Inherits from
Generic: #call
Executes each request in a dedicated Ruby 4.1 Ractor.
Definitions
def initialize(delegate)
Initialize a Ractored executor.
Signature
-
parameter
delegateInterface(:call) A shareable HTTP application.
Implementation
def initialize(delegate)
unless self.class.supported?
raise NotImplementedError, "Ractor execution requires the Ruby head/4.1 Ractor API."
end
unless ::Ractor.shareable?(delegate)
raise ArgumentError, "The Ractor application must be shareable."
end
# Protocol::HTTP applications construct headers inside the worker, so the
# default policy must be visible from non-main Ractors:
::Ractor.make_shareable(::Protocol::HTTP::Headers::POLICY)
super
end
def self.supported?
Signature
-
returns
Boolean Whether the required Ractor API is available.
Implementation
def self.supported?
defined?(::Ractor) && ::Ractor.method_defined?(:join) && ::Ractor.method_defined?(:value)
end