| 18 | |
| 19 | |
| 20 | comm::RetCode GetPubIDsByStoreID(const int topic_id, const int store_id, set<int> &pub_ids) { |
| 21 | pub_ids.clear(); |
| 22 | |
| 23 | comm::RetCode ret; |
| 24 | |
| 25 | shared_ptr<const StoreConfig> store_config; |
| 26 | if (comm::RetCode::RET_OK != (ret = GlobalConfig::GetThreadInstance()->GetStoreConfig(topic_id, store_config))) { |
| 27 | NLErr("GetStoreConfig ret %d topic_id %d", comm::as_integer(ret), topic_id); |
| 28 | return ret; |
| 29 | } |
| 30 | |
| 31 | shared_ptr<const proto::Store> store; |
| 32 | if (comm::RetCode::RET_OK != (ret = store_config->GetStoreByStoreID(store_id, store))) { |
| 33 | NLErr("GetStoreByStoreID ret %d", comm::as_integer(ret)); |
| 34 | return ret; |
| 35 | } |
| 36 | |
| 37 | shared_ptr<const TopicConfig> topic_config; |
| 38 | if (comm::RetCode::RET_OK != (ret = GlobalConfig::GetThreadInstance()->GetTopicConfigByTopicID(topic_id, topic_config))) { |
| 39 | NLErr("GetTopicConfig ret %d topic_id %d", comm::as_integer(ret), topic_id); |
| 40 | return ret; |
| 41 | } |
| 42 | |
| 43 | if (store->pub_ids_size()) { |
| 44 | for (int i{0}; i < store->pub_ids_size(); ++i) { |
| 45 | auto &&pub_id = store->pub_ids(i); |
| 46 | if (topic_config->IsValidPubID(pub_id)) { |
| 47 | pub_ids.insert(store->pub_ids(i)); |
| 48 | } |
| 49 | } |
| 50 | return comm::RetCode::RET_OK; |
| 51 | } |
| 52 | |
| 53 | if (comm::RetCode::RET_OK != (ret = topic_config->GetAllPubID(pub_ids))) { |
| 54 | NLErr("GetAllPubID ret %d", comm::as_integer(ret)); |
| 55 | } |
| 56 | |
| 57 | return ret; |
| 58 | } |
| 59 | |
| 60 | |
| 61 | } // namespace utils |
no test coverage detected