29 {
30 RoutingConfig routing_conf;
32 << "Unable to load routing conf file: "
34
36 << " is loaded.";
37
39 attr.set_channel_name(routing_conf.topic_config().routing_response_topic());
40 auto qos = attr.mutable_qos_profile();
42 qos->set_reliability(
44 qos->set_durability(
46 response_writer_ =
node_->CreateWriter<routing::RoutingResponse>(attr);
47
49 attr_history.set_channel_name(
50 routing_conf.topic_config().routing_response_history_topic());
51 auto qos_history = attr_history.mutable_qos_profile();
52 qos_history->set_history(
54 qos_history->set_reliability(
56 qos_history->set_durability(
58
59 response_history_writer_ =
60 node_->CreateWriter<routing::RoutingResponse>(attr_history);
61 std::weak_ptr<RoutingComponent> self =
62 std::dynamic_pointer_cast<RoutingComponent>(shared_from_this());
63 timer_.reset(new ::apollo::cyber::Timer(
64 FLAGS_routing_response_history_interval_ms,
65 [self, this]() {
66 auto ptr = self.lock();
67 if (ptr) {
68 std::lock_guard<std::mutex> guard(this->mutex_);
69 if (this->response_ != nullptr) {
71 response_->mutable_header()->set_timestamp_sec(timestamp);
72 this->response_history_writer_->Write(*response_);
73 }
74 }
75 },
76 false));
77 timer_->Start();
78
80}
bool ok() const
check whether the return status is OK.
static double NowInSeconds()
gets the current time in second.
bool GetProtoConfig(T *config) const
const std::string & ConfigFilePath() const
std::shared_ptr< Node > node_
apollo::common::Status Init()
module initialization function
apollo::common::Status Start()
module start function
@ DURABILITY_TRANSIENT_LOCAL