You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.2 KiB

  1. /*
  2. * node-rdkafka - Node.js wrapper for RdKafka C/C++ library
  3. *
  4. * Copyright (c) 2016 Blizzard Entertainment
  5. *
  6. * This software may be modified and distributed under the terms
  7. * of the MIT license. See the LICENSE.txt file for details.
  8. */
  9. var librdkafka = require('../librdkafka');
  10. module.exports = Topic;
  11. var topicKey = 'RdKafka::Topic::';
  12. var topicKeyLength = topicKey.length;
  13. // Take all of the topic special codes from librdkafka and add them
  14. // to the object
  15. // You can find this list in the C++ code at
  16. // https://github.com/edenhill/librdkafka/blob/master/src-cpp/rdkafkacpp.h#L1250
  17. for (var key in librdkafka.topic) {
  18. // Skip it if it doesn't start with ErrorCode
  19. if (key.indexOf('RdKafka::Topic::') !== 0) {
  20. continue;
  21. }
  22. // Replace/add it if there are any discrepancies
  23. var newKey = key.substring(topicKeyLength);
  24. Topic[newKey] = librdkafka.topic[key];
  25. }
  26. /**
  27. * Create a topic. Just returns the string you gave it right now.
  28. *
  29. * Looks like a class, but all it does is return the topic name.
  30. * This is so that one day if there are interface changes that allow
  31. * different use of topic parameters, we can just add to this constructor and
  32. * have it return something richer
  33. */
  34. function Topic(topicName) {
  35. return topicName;
  36. }