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.
610 611 612 613 614 615 616 617 |
# File 'lib/rage/configuration.rb', line 610 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.
640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 |
# File 'lib/rage/configuration.rb', line 640 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.
676 677 678 |
# File 'lib/rage/configuration.rb', line 676 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.
706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 |
# File 'lib/rage/configuration.rb', line 706 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 |