Class: S3arch::Configuration
- Inherits:
-
Object
- Object
- S3arch::Configuration
- Defined in:
- lib/s3arch/configuration.rb
Instance Attribute Summary collapse
-
#ephemeral_storage_mb ⇒ Object
Returns the value of attribute ephemeral_storage_mb.
-
#index_bucket ⇒ Object
Returns the value of attribute index_bucket.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#max_cached_dbs ⇒ Object
Returns the value of attribute max_cached_dbs.
-
#max_results ⇒ Object
Returns the value of attribute max_results.
-
#metadata_fields ⇒ Object
Returns the value of attribute metadata_fields.
-
#owner_extractor ⇒ Object
Returns the value of attribute owner_extractor.
-
#owner_key ⇒ Object
Returns the value of attribute owner_key.
-
#record_filter ⇒ Object
Returns the value of attribute record_filter.
-
#searchable_fields ⇒ Object
Returns the value of attribute searchable_fields.
-
#source_index ⇒ Object
Returns the value of attribute source_index.
-
#source_table ⇒ Object
Returns the value of attribute source_table.
-
#version_table ⇒ Object
Returns the value of attribute version_table.
-
#version_ttl ⇒ Object
Returns the value of attribute version_ttl.
Instance Method Summary collapse
- #from_env! ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/s3arch/configuration.rb', line 9 def initialize @owner_key = 'user_id' @searchable_fields = %w[name description] @metadata_fields = %w[status created_at] @record_filter = ->(_record) { true } @owner_extractor = ->(stream_record) { image = stream_record.dig('dynamodb', 'NewImage') || stream_record.dig('dynamodb', 'OldImage') || {} image.dig(owner_key, 'S') } @version_ttl = 30 @max_results = 50 @max_cached_dbs = 20 @ephemeral_storage_mb = 2048 @logger = nil end |
Instance Attribute Details
#ephemeral_storage_mb ⇒ Object
Returns the value of attribute ephemeral_storage_mb.
5 6 7 |
# File 'lib/s3arch/configuration.rb', line 5 def ephemeral_storage_mb @ephemeral_storage_mb end |
#index_bucket ⇒ Object
Returns the value of attribute index_bucket.
5 6 7 |
# File 'lib/s3arch/configuration.rb', line 5 def index_bucket @index_bucket end |
#logger ⇒ Object
Returns the value of attribute logger.
5 6 7 |
# File 'lib/s3arch/configuration.rb', line 5 def logger @logger end |
#max_cached_dbs ⇒ Object
Returns the value of attribute max_cached_dbs.
5 6 7 |
# File 'lib/s3arch/configuration.rb', line 5 def max_cached_dbs @max_cached_dbs end |
#max_results ⇒ Object
Returns the value of attribute max_results.
5 6 7 |
# File 'lib/s3arch/configuration.rb', line 5 def max_results @max_results end |
#metadata_fields ⇒ Object
Returns the value of attribute metadata_fields.
5 6 7 |
# File 'lib/s3arch/configuration.rb', line 5 def @metadata_fields end |
#owner_extractor ⇒ Object
Returns the value of attribute owner_extractor.
5 6 7 |
# File 'lib/s3arch/configuration.rb', line 5 def owner_extractor @owner_extractor end |
#owner_key ⇒ Object
Returns the value of attribute owner_key.
5 6 7 |
# File 'lib/s3arch/configuration.rb', line 5 def owner_key @owner_key end |
#record_filter ⇒ Object
Returns the value of attribute record_filter.
5 6 7 |
# File 'lib/s3arch/configuration.rb', line 5 def record_filter @record_filter end |
#searchable_fields ⇒ Object
Returns the value of attribute searchable_fields.
5 6 7 |
# File 'lib/s3arch/configuration.rb', line 5 def searchable_fields @searchable_fields end |
#source_index ⇒ Object
Returns the value of attribute source_index.
5 6 7 |
# File 'lib/s3arch/configuration.rb', line 5 def source_index @source_index end |
#source_table ⇒ Object
Returns the value of attribute source_table.
5 6 7 |
# File 'lib/s3arch/configuration.rb', line 5 def source_table @source_table end |
#version_table ⇒ Object
Returns the value of attribute version_table.
5 6 7 |
# File 'lib/s3arch/configuration.rb', line 5 def version_table @version_table end |
#version_ttl ⇒ Object
Returns the value of attribute version_ttl.
5 6 7 |
# File 'lib/s3arch/configuration.rb', line 5 def version_ttl @version_ttl end |
Instance Method Details
#from_env! ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/s3arch/configuration.rb', line 25 def from_env! @source_table = ENV['S3ARCH_SOURCE_TABLE'] @source_index = ENV['S3ARCH_SOURCE_INDEX'] || 'UserIndex' @index_bucket = ENV['S3ARCH_INDEX_BUCKET'] @version_table = ENV['S3ARCH_VERSION_TABLE'] self end |
#validate! ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/s3arch/configuration.rb', line 33 def validate! missing = [] missing << 'source_table' unless source_table missing << 'index_bucket' unless index_bucket missing << 'version_table' unless version_table missing << 'source_index' unless source_index raise Error, "S3arch configuration missing: #{missing.join(', ')}" if missing.any? end |