| 564 | } |
| 565 | |
| 566 | comm::RetCode Consumer::Process(comm::proto::ConsumerContext &cc) { |
| 567 | |
| 568 | QLInfo("cc.sub_id %d cc.store_id %d cc.queue_id %d", cc.sub_id(), cc.store_id(), cc.queue_id()); |
| 569 | |
| 570 | comm::RetCode ret; |
| 571 | |
| 572 | shared_ptr<const config::TopicConfig> topic_config; |
| 573 | if (comm::RetCode::RET_OK != (ret = config::GlobalConfig::GetThreadInstance()->GetTopicConfigByTopicID(impl_->topic_id, topic_config))) { |
| 574 | QLErr("GetTopicConfigByTopicID ret %d topic_id %d", comm::as_integer(ret), impl_->topic_id); |
| 575 | return ret; |
| 576 | } |
| 577 | |
| 578 | if (!topic_config->IsValidQueue(cc.queue_id(), -1, cc.sub_id())) { |
| 579 | QLErr("IsValidQueue return false queue_id %d", cc.queue_id()); |
| 580 | return comm::RetCode::RET_ERR_RANGE_QUEUE; |
| 581 | } |
| 582 | |
| 583 | shared_ptr<const config::proto::QueueInfo> queue_info; |
| 584 | if (comm::RetCode::RET_OK != (ret = topic_config->GetQueueInfoByQueue(cc.queue_id(), queue_info))) { |
| 585 | QLErr("GetQueueInfoByQueue ret %d queue_id %d", comm::as_integer(ret), cc.queue_id()); |
| 586 | return ret; |
| 587 | } |
| 588 | |
| 589 | const int topic_id{topic_config->GetProto().topic().topic_id()}; |
| 590 | |
| 591 | uint32_t maxlimit{topic_config->GetProto().topic().batch_limit()}; |
| 592 | uint32_t limit{topic_config->GetProto().topic().batch_limit()}; |
| 593 | |
| 594 | const int sleep_us_per_get = queue_info->sleep_us_per_get(); |
| 595 | const int sleep_us_on_get_fail = queue_info->sleep_us_on_get_fail(); |
| 596 | const int sleep_us_on_get_no_item = queue_info->sleep_us_on_get_no_item(); |
| 597 | const int sleep_us_on_get_size_too_small = queue_info->sleep_us_on_get_size_too_small(); |
| 598 | |
| 599 | |
| 600 | const int queue_delay{queue_info->delay()}; |
| 601 | if (queue_delay < 0) { |
| 602 | comm::ConsumerBP::GetThreadInstance()->OnGetQueueDelayFail(cc); |
| 603 | QLErr("GetQueueDelay ret %d", queue_delay); |
| 604 | return comm::RetCode::RET_ERR_RANGE; |
| 605 | } |
| 606 | |
| 607 | auto start_loop_time = comm::utils::Time::GetSteadyClockMS(); |
| 608 | |
| 609 | |
| 610 | static double freq_quota = 0; |
| 611 | static uint64_t last_fill_time = 0; |
| 612 | |
| 613 | static uint64_t last_topic_config_mod_time = 0; |
| 614 | { |
| 615 | auto new_topic_config_mod_time = topic_config->GetLastModTime(); |
| 616 | if (last_topic_config_mod_time != new_topic_config_mod_time) { |
| 617 | last_topic_config_mod_time = new_topic_config_mod_time; |
| 618 | if (freq_quota > 0) freq_quota = 0; |
| 619 | } |
| 620 | } |
| 621 | |
| 622 | while (true) { |
| 623 | comm::ConsumerBP::GetThreadInstance()->OnLoop(cc); |
nothing calls this directly
no test coverage detected