twitter.js 902 B

1234567891011121314151617181920212223242526272829
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. const log4js = require("log4js");
  4. const logger = log4js.getLogger('twitter');
  5. logger.level = 'info';
  6. function work(lock) {
  7. if (lock.feed.length === 0) {
  8. setTimeout(() => {
  9. work(lock);
  10. }, 60000);
  11. return;
  12. }
  13. if (lock.workon >= lock.feed.length)
  14. lock.workon = 0;
  15. if (!lock.threads[lock.feed[lock.workon]] ||
  16. !lock.threads[lock.feed[lock.workon]].subscribers ||
  17. lock.threads[lock.feed[lock.workon]].subscribers.length === 0) {
  18. logger.error(`nobody subscribes thread ${lock.feed[lock.workon]}, removing from feed`);
  19. lock.feed.splice(lock.workon, 1);
  20. work(lock);
  21. return;
  22. }
  23. // TODO: Work on lock.feed[lock.workon]
  24. lock.workon++;
  25. setTimeout(() => {
  26. work(lock);
  27. }, 60000);
  28. }
  29. exports.default = work;