Class: VendorsService::GoogleReserve::AvailabilityFeeds::SchedulerService
- Inherits:
-
Object
- Object
- VendorsService::GoogleReserve::AvailabilityFeeds::SchedulerService
- Includes:
- ElasticAPM::SpanHelpers, Concerns::FeedUploader
- Defined in:
- app/services/vendors_service/google_reserve/availability_feeds/scheduler_service.rb
Constant Summary collapse
- UPLOAD_DELAY_MINUTES =
Delay in minutes before scheduling upload workers after processing starts
15
Instance Method Summary collapse
-
#call ⇒ void
Coordinates the entire feed generation process - Deletes all existing feed fragments for a clean start - Schedules individual restaurant processing workers - Schedules separate upload workers for each shard with delay.
Instance Method Details
#call ⇒ void
This method returns an undefined value.
Coordinates the entire feed generation process
-
Deletes all existing feed fragments for a clean start
-
Schedules individual restaurant processing workers
-
Schedules separate upload workers for each shard with delay
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 58 59 60 |
# File 'app/services/vendors_service/google_reserve/availability_feeds/scheduler_service.rb', line 24 def call setup_business_context cleanup_existing_fragments eligible_restaurant_ids = collect_eligible_restaurant_ids return if no_eligible_restaurants?(eligible_restaurant_ids) # Generate a single timestamp for all shards to ensure consistency @generation_timestamp = Time.current.to_i.to_s # Get total shards from admin settings total_shards = AdminSetting.google_reserve_availability_feeds_total_shards # Assign restaurants to shards and create fragment records shard_assignments = assign_restaurants_to_shards(eligible_restaurant_ids, total_shards) create_pending_fragment_records_with_shards(shard_assignments) # Schedule restaurant processing workers schedule_restaurant_processing_workers(eligible_restaurant_ids) # Schedule separate upload workers for each shard schedule_shard_upload_workers(shard_assignments) log_completion(eligible_restaurant_ids.count, total_shards) rescue StandardError => e = 'Failed to schedule availability feed generation' error_context = { service: self.class.name, operation: 'call', restaurants_count: eligible_restaurant_ids&.count || 0, error_class: e.class.name, error_message: e., } BUSINESS_LOGGER.error(, **error_context) APMErrorHandler.report(e, context: error_context) raise e end |