Module: Carson::Runtime::Receive
- Included in:
- Carson::Runtime
- Defined in:
- lib/carson/runtime/receive.rb
Instance Method Summary collapse
-
#receive!(dry_run: false, json_output: false, loop_seconds: nil) ⇒ Object
Single-repo entry point.
- #receive_cycle!(dry_run:, json_output:) ⇒ Object
- #receive_loop!(dry_run:, json_output:, loop_seconds:) ⇒ Object
Instance Method Details
#receive!(dry_run: false, json_output: false, loop_seconds: nil) ⇒ Object
Single-repo entry point. Advances deliveries for the current repository.
10 11 12 13 14 15 16 |
# File 'lib/carson/runtime/receive.rb', line 10 def receive!( dry_run: false, json_output: false, loop_seconds: nil ) if loop_seconds receive_loop!( dry_run: dry_run, json_output: json_output, loop_seconds: loop_seconds ) else receive_cycle!( dry_run: dry_run, json_output: json_output ) end end |
#receive_cycle!(dry_run:, json_output:) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/carson/runtime/receive.rb', line 18 def receive_cycle!( dry_run:, json_output: ) repo_path = repository_record.path repo_name = File.basename( repo_path ) print_header "Receiving #{repo_name}" unless json_output repo_report = receive_repo!( repo_path: repo_path, dry_run: dry_run, silent: json_output ) report = { cycle_at: Time.now.utc.iso8601, dry_run: dry_run, repository: repo_report } if json_output output.puts JSON.pretty_generate( report ) else print_receive_summary( repo_report: repo_report ) end EXIT_OK rescue StandardError => exception puts_line "Receive did not complete: #{exception.}" EXIT_ERROR end |
#receive_loop!(dry_run:, json_output:, loop_seconds:) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/carson/runtime/receive.rb', line 42 def receive_loop!( dry_run:, json_output:, loop_seconds: ) run_signal_aware_loop!( loop_name: "receive", loop_seconds: loop_seconds, cycle_line: ->( cycle_count ) { "cycle #{cycle_count} at #{Time.now.utc.strftime( '%Y-%m-%d %H:%M:%S UTC' )}" }, sleep_line: ->( seconds ) do next_at = Time.now + seconds "sleeping #{seconds}s — next cycle at #{next_at.strftime( '%Y-%m-%d %H:%M:%S %z' )}" end ) do receive_cycle!( dry_run: dry_run, json_output: json_output ) end end |