Class: Angarium::Configuration
- Inherits:
-
Object
- Object
- Angarium::Configuration
- Defined in:
- lib/angarium/configuration.rb
Instance Attribute Summary collapse
-
#auto_disable_endpoint_after ⇒ Object
Returns the value of attribute auto_disable_endpoint_after.
-
#block_private_ips ⇒ Object
Returns the value of attribute block_private_ips.
-
#connects_to ⇒ Object
Returns the value of attribute connects_to.
-
#current_user ⇒ Object
Returns the value of attribute current_user.
-
#database ⇒ Object
Returns the value of attribute database.
-
#delivering_timeout ⇒ Object
Returns the value of attribute delivering_timeout.
-
#delivery_attempt_retention ⇒ Object
Returns the value of attribute delivery_attempt_retention.
-
#dns_timeout ⇒ Object
Returns the value of attribute dns_timeout.
-
#http_timeout ⇒ Object
Returns the value of attribute http_timeout.
-
#job_queue ⇒ Object
Returns the value of attribute job_queue.
-
#max_response_body_bytes ⇒ Object
Returns the value of attribute max_response_body_bytes.
-
#max_retry_after ⇒ Object
Returns the value of attribute max_retry_after.
-
#max_subscribed_events ⇒ Object
Returns the value of attribute max_subscribed_events.
-
#max_url_length ⇒ Object
Returns the value of attribute max_url_length.
-
#on_delivery_exhausted ⇒ Object
Returns the value of attribute on_delivery_exhausted.
-
#on_endpoint_deactivated ⇒ Object
Returns the value of attribute on_endpoint_deactivated.
-
#on_endpoint_verified ⇒ Object
Returns the value of attribute on_endpoint_verified.
-
#open_timeout ⇒ Object
Returns the value of attribute open_timeout.
-
#parent_controller ⇒ Object
Returns the value of attribute parent_controller.
-
#ping_event_name ⇒ Object
Returns the value of attribute ping_event_name.
-
#policy_class ⇒ Object
Returns the value of attribute policy_class.
-
#primary_key_type ⇒ Object
Returns the value of attribute primary_key_type.
-
#resolve_dns_with_hosts_file ⇒ Object
Returns the value of attribute resolve_dns_with_hosts_file.
-
#respect_retry_after ⇒ Object
Returns the value of attribute respect_retry_after.
-
#retry_jitter ⇒ Object
Returns the value of attribute retry_jitter.
-
#retry_schedule ⇒ Object
Returns the value of attribute retry_schedule.
-
#signing_secret_grace_period ⇒ Object
Returns the value of attribute signing_secret_grace_period.
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#migrations_database ⇒ Object
The database Angarium's migrations belong in, for the migrations generator.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/angarium/configuration.rb', line 14 def initialize @job_queue = :default @http_timeout = 10 @open_timeout = 5 @user_agent = "Angarium/#{Angarium::VERSION}" # Follows the Standard Webhooks recommendation of a multi-day schedule with # exponential backoff (delays between retries; the first delivery is # immediate). Spans ~10 days; jitter is added per attempt (see # config.retry_jitter). @retry_schedule = [ 5.seconds, 5.minutes, 30.minutes, 2.hours, 5.hours, 10.hours, 14.hours, 20.hours, 24.hours, 36.hours, 48.hours, 72.hours ] @block_private_ips = true @primary_key_type = nil # Multi-database: the database (a key from config/database.yml) that # Angarium's tables live in. Drives both the connection and where the # migrations generator installs migrations (db/<database>_migrate). # nil (default) keeps Angarium on the app's primary connection. @database = nil # Advanced multi-database: a hash passed straight to Rails' connects_to for # custom roles/shards, e.g. { database: { writing: :angarium, reading: :angarium } }. # Takes precedence over @database for the connection. @connects_to = nil @max_response_body_bytes = 65_536 # Disable an endpoint after this many consecutive *failed deliveries* (a # delivery that exhausts its whole retry schedule, or is blocked by the SSRF # guard) — NOT individual failed HTTP attempts. A single delivery that # retries and eventually gives up counts as one. nil disables auto-disable. @auto_disable_endpoint_after = nil @respect_retry_after = true @max_retry_after = 3600 @retry_jitter = 0.15 @signing_secret_grace_period = 24.hours @delivery_attempt_retention = nil @delivering_timeout = 15.minutes # Per-try timeout(s), in seconds, for resolving an endpoint host before # delivery. Bounds how long a hostile or misconfigured slow-resolving host # can stall a delivery worker (Resolv::DNS retries across the array). Set to # nil to use the resolver's own defaults. @dns_timeout = [1, 3] # Whether host resolution also consults the system hosts file (/etc/hosts), # not just DNS. Default true, so an internal endpoint pinned via /etc/hosts # resolves as expected. Set false to harden a deployment to DNS-only. @resolve_dns_with_hosts_file = true # Max length of an endpoint URL and the cap on how many event patterns an # endpoint may subscribe to (each pattern is replayed by EventMatcher on # every dispatch). Both bound user-supplied input. @max_url_length = 2048 @max_subscribed_events = 100 # Event name of the synthetic event emitted by Endpoint#ping!. Configurable # so it won't collide with an application that already uses "ping" for its # own events (and so pings can be routed/filtered distinctly). @ping_event_name = "ping" @on_delivery_exhausted = nil # ->(delivery) { ... } @on_endpoint_deactivated = nil # ->(endpoint, reason) { ... } reason: :consecutive_failures | :gone @on_endpoint_verified = nil # ->(endpoint) { ... } fired when an unverified endpoint is verified # --- Headless JSON API (only used if you mount Angarium::Engine) --------- # Base controller the API inherits from, so your app's authentication # (Devise/Rodauth/etc.) applies to Angarium's endpoints too. @parent_controller = "ApplicationController" # Resolves the current user from the controller (your current-user convention). @current_user = ->(controller) { controller.current_user } # Authorization: scope, create-owner, and per-action permissions, all in one # class. Subclass Angarium::Api::Policy to customize any of them. @policy_class = "Angarium::Api::Policy" end |
Instance Attribute Details
#auto_disable_endpoint_after ⇒ Object
Returns the value of attribute auto_disable_endpoint_after.
3 4 5 |
# File 'lib/angarium/configuration.rb', line 3 def auto_disable_endpoint_after @auto_disable_endpoint_after end |
#block_private_ips ⇒ Object
Returns the value of attribute block_private_ips.
3 4 5 |
# File 'lib/angarium/configuration.rb', line 3 def block_private_ips @block_private_ips end |
#connects_to ⇒ Object
Returns the value of attribute connects_to.
3 4 5 |
# File 'lib/angarium/configuration.rb', line 3 def connects_to @connects_to end |
#current_user ⇒ Object
Returns the value of attribute current_user.
3 4 5 |
# File 'lib/angarium/configuration.rb', line 3 def current_user @current_user end |
#database ⇒ Object
Returns the value of attribute database.
3 4 5 |
# File 'lib/angarium/configuration.rb', line 3 def database @database end |
#delivering_timeout ⇒ Object
Returns the value of attribute delivering_timeout.
3 4 5 |
# File 'lib/angarium/configuration.rb', line 3 def delivering_timeout @delivering_timeout end |
#delivery_attempt_retention ⇒ Object
Returns the value of attribute delivery_attempt_retention.
3 4 5 |
# File 'lib/angarium/configuration.rb', line 3 def delivery_attempt_retention @delivery_attempt_retention end |
#dns_timeout ⇒ Object
Returns the value of attribute dns_timeout.
3 4 5 |
# File 'lib/angarium/configuration.rb', line 3 def dns_timeout @dns_timeout end |
#http_timeout ⇒ Object
Returns the value of attribute http_timeout.
3 4 5 |
# File 'lib/angarium/configuration.rb', line 3 def http_timeout @http_timeout end |
#job_queue ⇒ Object
Returns the value of attribute job_queue.
3 4 5 |
# File 'lib/angarium/configuration.rb', line 3 def job_queue @job_queue end |
#max_response_body_bytes ⇒ Object
Returns the value of attribute max_response_body_bytes.
3 4 5 |
# File 'lib/angarium/configuration.rb', line 3 def max_response_body_bytes @max_response_body_bytes end |
#max_retry_after ⇒ Object
Returns the value of attribute max_retry_after.
3 4 5 |
# File 'lib/angarium/configuration.rb', line 3 def max_retry_after @max_retry_after end |
#max_subscribed_events ⇒ Object
Returns the value of attribute max_subscribed_events.
3 4 5 |
# File 'lib/angarium/configuration.rb', line 3 def max_subscribed_events @max_subscribed_events end |
#max_url_length ⇒ Object
Returns the value of attribute max_url_length.
3 4 5 |
# File 'lib/angarium/configuration.rb', line 3 def max_url_length @max_url_length end |
#on_delivery_exhausted ⇒ Object
Returns the value of attribute on_delivery_exhausted.
3 4 5 |
# File 'lib/angarium/configuration.rb', line 3 def on_delivery_exhausted @on_delivery_exhausted end |
#on_endpoint_deactivated ⇒ Object
Returns the value of attribute on_endpoint_deactivated.
3 4 5 |
# File 'lib/angarium/configuration.rb', line 3 def on_endpoint_deactivated @on_endpoint_deactivated end |
#on_endpoint_verified ⇒ Object
Returns the value of attribute on_endpoint_verified.
3 4 5 |
# File 'lib/angarium/configuration.rb', line 3 def on_endpoint_verified @on_endpoint_verified end |
#open_timeout ⇒ Object
Returns the value of attribute open_timeout.
3 4 5 |
# File 'lib/angarium/configuration.rb', line 3 def open_timeout @open_timeout end |
#parent_controller ⇒ Object
Returns the value of attribute parent_controller.
3 4 5 |
# File 'lib/angarium/configuration.rb', line 3 def parent_controller @parent_controller end |
#ping_event_name ⇒ Object
Returns the value of attribute ping_event_name.
3 4 5 |
# File 'lib/angarium/configuration.rb', line 3 def ping_event_name @ping_event_name end |
#policy_class ⇒ Object
Returns the value of attribute policy_class.
3 4 5 |
# File 'lib/angarium/configuration.rb', line 3 def policy_class @policy_class end |
#primary_key_type ⇒ Object
Returns the value of attribute primary_key_type.
3 4 5 |
# File 'lib/angarium/configuration.rb', line 3 def primary_key_type @primary_key_type end |
#resolve_dns_with_hosts_file ⇒ Object
Returns the value of attribute resolve_dns_with_hosts_file.
3 4 5 |
# File 'lib/angarium/configuration.rb', line 3 def resolve_dns_with_hosts_file @resolve_dns_with_hosts_file end |
#respect_retry_after ⇒ Object
Returns the value of attribute respect_retry_after.
3 4 5 |
# File 'lib/angarium/configuration.rb', line 3 def respect_retry_after @respect_retry_after end |
#retry_jitter ⇒ Object
Returns the value of attribute retry_jitter.
3 4 5 |
# File 'lib/angarium/configuration.rb', line 3 def retry_jitter @retry_jitter end |
#retry_schedule ⇒ Object
Returns the value of attribute retry_schedule.
3 4 5 |
# File 'lib/angarium/configuration.rb', line 3 def retry_schedule @retry_schedule end |
#signing_secret_grace_period ⇒ Object
Returns the value of attribute signing_secret_grace_period.
3 4 5 |
# File 'lib/angarium/configuration.rb', line 3 def signing_secret_grace_period @signing_secret_grace_period end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
3 4 5 |
# File 'lib/angarium/configuration.rb', line 3 def user_agent @user_agent end |
Instance Method Details
#migrations_database ⇒ Object
The database Angarium's migrations belong in, for the migrations generator. Prefers the explicit @database, else the writing role from a connects_to hash. nil => the app's primary db/migrate.
86 87 88 |
# File 'lib/angarium/configuration.rb', line 86 def migrations_database database || connects_to&.dig(:database, :writing) end |