Class: Trainspotter::Ingest::Processor
- Inherits:
-
Struct
- Object
- Struct
- Trainspotter::Ingest::Processor
- Defined in:
- app/jobs/trainspotter/ingest/processor.rb
Constant Summary collapse
- DEFAULT_CHUNK_SIZE =
10_000
Instance Attribute Summary collapse
-
#chunk_size ⇒ Object
Returns the value of attribute chunk_size.
-
#log_path ⇒ Object
Returns the value of attribute log_path.
-
#session_builder ⇒ Object
Returns the value of attribute session_builder.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#chunk_size ⇒ Object
Returns the value of attribute chunk_size
3 4 5 |
# File 'app/jobs/trainspotter/ingest/processor.rb', line 3 def chunk_size @chunk_size end |
#log_path ⇒ Object
Returns the value of attribute log_path
3 4 5 |
# File 'app/jobs/trainspotter/ingest/processor.rb', line 3 def log_path @log_path end |
#session_builder ⇒ Object
Returns the value of attribute session_builder
3 4 5 |
# File 'app/jobs/trainspotter/ingest/processor.rb', line 3 def session_builder @session_builder end |
Class Method Details
.call(log_paths, chunk_size: DEFAULT_CHUNK_SIZE) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'app/jobs/trainspotter/ingest/processor.rb', line 6 def self.call(log_paths, chunk_size: DEFAULT_CHUNK_SIZE) session_builder = Ingest::SessionBuilder.new log_paths.each do |log_path| next unless File.exist?(log_path) new(log_path:, session_builder:, chunk_size:).call end end |
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 |
# File 'app/jobs/trainspotter/ingest/processor.rb', line 15 def call if position = unread_position process_chunk(position) expire_stale_sessions end end |