Class: Angarium::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/angarium/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



12
13
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
# File 'lib/angarium/configuration.rb', line 12

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
  @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
  @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_afterObject

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_ipsObject

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_toObject

Returns the value of attribute connects_to.



3
4
5
# File 'lib/angarium/configuration.rb', line 3

def connects_to
  @connects_to
end

#current_userObject

Returns the value of attribute current_user.



3
4
5
# File 'lib/angarium/configuration.rb', line 3

def current_user
  @current_user
end

#databaseObject

Returns the value of attribute database.



3
4
5
# File 'lib/angarium/configuration.rb', line 3

def database
  @database
end

#delivering_timeoutObject

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_retentionObject

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

#http_timeoutObject

Returns the value of attribute http_timeout.



3
4
5
# File 'lib/angarium/configuration.rb', line 3

def http_timeout
  @http_timeout
end

#job_queueObject

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_bytesObject

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_afterObject

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

#on_delivery_exhaustedObject

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_deactivatedObject

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_verifiedObject

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_timeoutObject

Returns the value of attribute open_timeout.



3
4
5
# File 'lib/angarium/configuration.rb', line 3

def open_timeout
  @open_timeout
end

#parent_controllerObject

Returns the value of attribute parent_controller.



3
4
5
# File 'lib/angarium/configuration.rb', line 3

def parent_controller
  @parent_controller
end

#policy_classObject

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_typeObject

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

#respect_retry_afterObject

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_jitterObject

Returns the value of attribute retry_jitter.



3
4
5
# File 'lib/angarium/configuration.rb', line 3

def retry_jitter
  @retry_jitter
end

#retry_scheduleObject

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_periodObject

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_agentObject

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_databaseObject

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.



62
63
64
# File 'lib/angarium/configuration.rb', line 62

def migrations_database
  database || connects_to&.dig(:database, :writing)
end