Class: Async::Background::Web::Configuration
- Inherits:
-
Object
- Object
- Async::Background::Web::Configuration
- Defined in:
- lib/async/background/web/configuration.rb
Constant Summary collapse
- DEFAULT_LIST_LIMIT =
50- MAX_LIST_LIMIT =
200- DEFAULT_COUNTS_TTL =
3.0- DEFAULT_POLL_INTERVAL_MS =
2000- DEFAULT_STREAM_POLL_SECONDS =
0.5- DEFAULT_STREAM_HEARTBEAT_SECONDS =
25.0- DEFAULT_STREAM_RETRY_MS =
5000- TRANSPORTS =
%i[polling sse].freeze
- DEFAULT_TRANSPORT =
:sse- DEFAULT_REDACT =
->(args) { args.is_a?(Array) ? args.map { '***' } : args }
Instance Attribute Summary collapse
-
#auth ⇒ Object
Returns the value of attribute auth.
-
#counts_cache_ttl ⇒ Object
Returns the value of attribute counts_cache_ttl.
-
#expose_args ⇒ Object
Returns the value of attribute expose_args.
-
#list_limit ⇒ Object
Returns the value of attribute list_limit.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#metrics_path ⇒ Object
Returns the value of attribute metrics_path.
-
#mount_path ⇒ Object
Returns the value of attribute mount_path.
-
#poll_interval_ms ⇒ Object
Returns the value of attribute poll_interval_ms.
-
#queue_path ⇒ Object
Returns the value of attribute queue_path.
-
#redact_args ⇒ Object
Returns the value of attribute redact_args.
-
#stream_heartbeat_seconds ⇒ Object
Returns the value of attribute stream_heartbeat_seconds.
-
#stream_poll_seconds ⇒ Object
Returns the value of attribute stream_poll_seconds.
-
#stream_retry_ms ⇒ Object
Returns the value of attribute stream_retry_ms.
-
#title ⇒ Object
Returns the value of attribute title.
-
#total_workers ⇒ Object
Returns the value of attribute total_workers.
-
#transport ⇒ Object
Returns the value of attribute transport.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#limit_for(requested) ⇒ Object
Strict request-path parsing.
- #metrics_enabled? ⇒ Boolean
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/async/background/web/configuration.rb', line 37 def initialize @queue_path = Queue::Store.default_path @auth = nil @expose_args = false @redact_args = DEFAULT_REDACT @metrics_path = nil @total_workers = nil @counts_cache_ttl = DEFAULT_COUNTS_TTL @list_limit = DEFAULT_LIST_LIMIT @poll_interval_ms = DEFAULT_POLL_INTERVAL_MS @transport = DEFAULT_TRANSPORT @stream_poll_seconds = DEFAULT_STREAM_POLL_SECONDS @stream_heartbeat_seconds = DEFAULT_STREAM_HEARTBEAT_SECONDS @stream_retry_ms = DEFAULT_STREAM_RETRY_MS @title = 'Async::Background' @mount_path = '' @logger = nil end |
Instance Attribute Details
#auth ⇒ Object
Returns the value of attribute auth.
20 21 22 |
# File 'lib/async/background/web/configuration.rb', line 20 def auth @auth end |
#counts_cache_ttl ⇒ Object
Returns the value of attribute counts_cache_ttl.
20 21 22 |
# File 'lib/async/background/web/configuration.rb', line 20 def counts_cache_ttl @counts_cache_ttl end |
#expose_args ⇒ Object
Returns the value of attribute expose_args.
20 21 22 |
# File 'lib/async/background/web/configuration.rb', line 20 def expose_args @expose_args end |
#list_limit ⇒ Object
Returns the value of attribute list_limit.
20 21 22 |
# File 'lib/async/background/web/configuration.rb', line 20 def list_limit @list_limit end |
#logger ⇒ Object
Returns the value of attribute logger.
20 21 22 |
# File 'lib/async/background/web/configuration.rb', line 20 def logger @logger end |
#metrics_path ⇒ Object
Returns the value of attribute metrics_path.
20 21 22 |
# File 'lib/async/background/web/configuration.rb', line 20 def metrics_path @metrics_path end |
#mount_path ⇒ Object
Returns the value of attribute mount_path.
20 21 22 |
# File 'lib/async/background/web/configuration.rb', line 20 def mount_path @mount_path end |
#poll_interval_ms ⇒ Object
Returns the value of attribute poll_interval_ms.
20 21 22 |
# File 'lib/async/background/web/configuration.rb', line 20 def poll_interval_ms @poll_interval_ms end |
#queue_path ⇒ Object
Returns the value of attribute queue_path.
20 21 22 |
# File 'lib/async/background/web/configuration.rb', line 20 def queue_path @queue_path end |
#redact_args ⇒ Object
Returns the value of attribute redact_args.
20 21 22 |
# File 'lib/async/background/web/configuration.rb', line 20 def redact_args @redact_args end |
#stream_heartbeat_seconds ⇒ Object
Returns the value of attribute stream_heartbeat_seconds.
20 21 22 |
# File 'lib/async/background/web/configuration.rb', line 20 def stream_heartbeat_seconds @stream_heartbeat_seconds end |
#stream_poll_seconds ⇒ Object
Returns the value of attribute stream_poll_seconds.
20 21 22 |
# File 'lib/async/background/web/configuration.rb', line 20 def stream_poll_seconds @stream_poll_seconds end |
#stream_retry_ms ⇒ Object
Returns the value of attribute stream_retry_ms.
20 21 22 |
# File 'lib/async/background/web/configuration.rb', line 20 def stream_retry_ms @stream_retry_ms end |
#title ⇒ Object
Returns the value of attribute title.
20 21 22 |
# File 'lib/async/background/web/configuration.rb', line 20 def title @title end |
#total_workers ⇒ Object
Returns the value of attribute total_workers.
20 21 22 |
# File 'lib/async/background/web/configuration.rb', line 20 def total_workers @total_workers end |
#transport ⇒ Object
Returns the value of attribute transport.
20 21 22 |
# File 'lib/async/background/web/configuration.rb', line 20 def transport @transport end |
Instance Method Details
#limit_for(requested) ⇒ Object
Strict request-path parsing. Silently changing a malformed requested page size to the default makes API clients repeat or skip work.
73 74 75 76 77 78 79 80 81 82 |
# File 'lib/async/background/web/configuration.rb', line 73 def limit_for(requested) return list_limit if requested.nil? || requested.empty? value = Integer(requested, 10) raise RequestError, 'limit must be a positive integer' unless value.positive? [value, MAX_LIST_LIMIT].min rescue ArgumentError, TypeError raise RequestError, 'limit must be a positive integer' end |
#metrics_enabled? ⇒ Boolean
84 85 86 |
# File 'lib/async/background/web/configuration.rb', line 84 def metrics_enabled? !metrics_path.nil? end |
#validate! ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/async/background/web/configuration.rb', line 56 def validate! validate_queue_path! validate_auth! validate_list_limit! validate_cache_ttl! validate_poll_interval! validate_transport! validate_stream! validate_redactor! validate_metrics! validate_mount_path! validate_logger! self end |