Class: Rage::Configuration::Deferred
- Inherits:
-
Object
- Object
- Rage::Configuration::Deferred
- Defined in:
- lib/rage/configuration.rb
Defined Under Namespace
Classes: Backpressure
Instance Method Summary collapse
-
#backend ⇒ Object
Returns the backend instance used by
Rage::Deferred. -
#backend=(config) ⇒ Object
Specify the backend used to persist deferred tasks.
-
#backpressure ⇒ Backpressure?
Returns the backpressure configuration used by
Rage::Deferred. -
#backpressure=(config) ⇒ Object
Configure backpressure settings for
Rage::Deferred.
Instance Method Details
#backend ⇒ Object
Returns the backend instance used by Rage::Deferred.
618 619 620 621 622 623 624 625 |
# File 'lib/rage/configuration.rb', line 618 def backend unless @backend_class @backend_class = Rage::Deferred::Backends::Disk @backend_options = ({}) end @backend_class.new(**@backend_options) end |
#backend=(disk, options = {}) ⇒ Object #backend=(nil) ⇒ Object
Specify the backend used to persist deferred tasks. Supported values are :disk, which uses disk storage, or nil, which disables persistence of deferred tasks.
648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 |
# File 'lib/rage/configuration.rb', line 648 def backend=(config) @configured = true backend_id, opts = if config.is_a?(Array) [config[0], config[1]] else [config, {}] end @backend_class = case backend_id when :disk @backend_options = (opts) Rage::Deferred::Backends::Disk when nil Rage::Deferred::Backends::Nil else raise ArgumentError, "unsupported backend value; supported keys are `:disk` and `nil`" end end |
#backpressure ⇒ Backpressure?
Returns the backpressure configuration used by Rage::Deferred.
684 685 686 |
# File 'lib/rage/configuration.rb', line 684 def backpressure @backpressure end |
#backpressure=(true) ⇒ Object #backpressure=(false) ⇒ Object #backpressure=(config) ⇒ Object
Configure backpressure settings for Rage::Deferred. Backpressure is used to limit the number of pending tasks in the queue and is disabled by default.
714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 |
# File 'lib/rage/configuration.rb', line 714 def backpressure=(config) @configured = true if config == true @backpressure = Backpressure.new return elsif config == false @backpressure = nil return end if config.except(:high_water_mark, :low_water_mark, :timeout).any? raise ArgumentError, "unsupported backpressure options; supported keys are `:high_water_mark`, `:low_water_mark`, `:timeout`" end high_water_mark, low_water_mark, timeout = config.values_at(:high_water_mark, :low_water_mark, :timeout) @backpressure = Backpressure.new(high_water_mark, low_water_mark, timeout) end |