MCPcopy Create free account
hub / github.com/SNAS/openbmp / getTopicKey

Method getTopicKey

Server/src/kafka/KafkaTopicSelector.cpp:406–439  ·  view source on GitHub ↗

* Get the topic map key name * * \param [in] topic_var MSGBUS_TOPIC_VAR_ * \param [in] router_group Router group - empty/NULL means no router group * \param [in] peer_group Peer group - empty/NULL means no peer group * \param [in] peer_asn Peer asn (remote asn) * * \return string value of the topic key to be used with the topic map */

Source from the content-addressed store, hash-verified

404 * \return string value of the topic key to be used with the topic map
405 */
406std::string KafkaTopicSelector::getTopicKey(const std::string &topic_var,
407 const std::string *router_group, const std::string *peer_group,
408 uint32_t peer_asn) {
409
410 std::string topic_key = topic_var;
411 char uint32_str[12];
412
413 // Update the topic name based on app variables
414 if (topic_var.compare(MSGBUS_TOPIC_VAR_COLLECTOR)) { // if not collector topic
415 topic_key += "_";
416
417 if (router_group != NULL and router_group->size() > 0) {
418 topic_key += *router_group;
419 }
420
421 if (topic_var.compare(MSGBUS_TOPIC_VAR_ROUTER)) { // if not router topic
422 topic_key += "_";
423
424 if (peer_group != NULL and peer_group->size() > 0) {
425 topic_key += *peer_group;
426 }
427
428 if (topic_flags_map[topic_var].include_peerAsn) {
429 topic_key += "_";
430 if (peer_asn > 0) {
431 snprintf(uint32_str, sizeof(uint32_str), "%u", peer_asn);
432 topic_key += uint32_str;
433 }
434 }
435 }
436 }
437
438 return topic_key;
439}
440
441/**
442 * Free allocated topic map pointers

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected