module Balance
Built-in backend selection policies.
Nested Classes and Modules
class SpreadPrefer the backend with the fewest active requests.
class PackPrefer a backend which is already processing the same class of work.
Definitions
def self.coerce(policy, **options)
Resolve a built-in policy name or validate an application policy object.
Signature
-
parameter
policySymbol | #select The policy name or object.
-
parameter
optionsHash Options for a built-in policy.
-
returns
#select The resolved balance policy.
Implementation
def self.coerce(policy, **options)
case policy
when :spread
Spread.new(**options)
when :pack
Pack.new(**options)
else
unless policy.respond_to?(:select)
raise ArgumentError, "Balance policy must respond to #select!"
end
policy
end
end