Class: BulkCsvParser::Configuration
- Inherits:
-
Object
- Object
- BulkCsvParser::Configuration
- Defined in:
- lib/bulk_csv_parser/configuration.rb
Instance Attribute Summary collapse
-
#batch_size ⇒ Object
Rows read into memory per batch before a DB round-trip happens.
-
#mailer_sender ⇒ Object
Default "from" address for BulkCsvParser::ImportMailer.
-
#notify_error_limit ⇒ Object
Max number of row errors listed in the result notification email (the rest are summarized as a count, so the email doesn't balloon on a file with thousands of bad rows).
-
#queue_name ⇒ Object
ActiveJob queue used by BulkCsvParser::ImportJob.
-
#storage ⇒ Object
:active_storage -> uploads the CSV to whatever service is configured in config/storage.yml (S3/GCS/Azure).
-
#strategy ⇒ Object
:save -> find_or_initialize_by + assign_attributes + save (runs validations/callbacks) :upsert -> ActiveRecord#upsert_all (fast, bulk, skips validations/callbacks).
-
#upload_dir ⇒ Object
Directory used by the :local storage adapter.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
38 39 40 41 42 43 44 45 46 |
# File 'lib/bulk_csv_parser/configuration.rb', line 38 def initialize @batch_size = 1000 @strategy = :save @queue_name = :bulk_csv_parser @storage = defined?(::ActiveStorage) ? :active_storage : :local @upload_dir = defined?(Rails) ? Rails.root.join("tmp", "bulk_csv_parser") : "tmp/bulk_csv_parser" @mailer_sender = "no-reply@example.com" @notify_error_limit = 25 end |
Instance Attribute Details
#batch_size ⇒ Object
Rows read into memory per batch before a DB round-trip happens.
6 7 8 |
# File 'lib/bulk_csv_parser/configuration.rb', line 6 def batch_size @batch_size end |
#mailer_sender ⇒ Object
Default "from" address for BulkCsvParser::ImportMailer.
31 32 33 |
# File 'lib/bulk_csv_parser/configuration.rb', line 31 def mailer_sender @mailer_sender end |
#notify_error_limit ⇒ Object
Max number of row errors listed in the result notification email (the rest are summarized as a count, so the email doesn't balloon on a file with thousands of bad rows).
36 37 38 |
# File 'lib/bulk_csv_parser/configuration.rb', line 36 def notify_error_limit @notify_error_limit end |
#queue_name ⇒ Object
ActiveJob queue used by BulkCsvParser::ImportJob
13 14 15 |
# File 'lib/bulk_csv_parser/configuration.rb', line 13 def queue_name @queue_name end |
#storage ⇒ Object
:active_storage -> uploads the CSV to whatever service is configured in
config/storage.yml (S3/GCS/Azure). Required whenever
the job's queue is processed by a different machine
than the one that received the upload, since a local
file path from the web server won't resolve on the
worker box. Falls back to :local automatically when
ActiveStorage isn't loaded.
:local -> copies the file to upload_dir on the local disk.
Only safe when web and worker share that disk (e.g.
single-machine deploys, or a shared NFS mount).
25 26 27 |
# File 'lib/bulk_csv_parser/configuration.rb', line 25 def storage @storage end |
#strategy ⇒ Object
:save -> find_or_initialize_by + assign_attributes + save (runs validations/callbacks) :upsert -> ActiveRecord#upsert_all (fast, bulk, skips validations/callbacks)
10 11 12 |
# File 'lib/bulk_csv_parser/configuration.rb', line 10 def strategy @strategy end |
#upload_dir ⇒ Object
Directory used by the :local storage adapter.
28 29 30 |
# File 'lib/bulk_csv_parser/configuration.rb', line 28 def upload_dir @upload_dir end |