lichao
2021-05-20 68c7bef33e74f23aa0136ccd6f7faa654d671ebc
box/node_center.h
@@ -80,17 +80,20 @@
   struct ProcState {
      int64_t timestamp_ = 0;
      uint32_t flag_ = 0; // reserved
      void PutOffline(const int64_t offline_time);
      void UpdateState(const int64_t now, const int64_t offline_time, const int64_t kill_time);
   };
   typedef std::unordered_map<Address, std::set<Topic>> AddressTopics;
   struct NodeInfo {
      NodeCenter &center_;
      ProcState state_;               // state
      std::map<MQId, int64_t> addrs_; // registered mqs
      ProcInfo proc_;                 //
      AddressTopics services_;        // address: topics
      AddressTopics subscriptions_;   // address: topics
      NodeInfo(NodeCenter &center) :
          center_(center) {}
      void PutOffline(const int64_t offline_time);
      void UpdateState(const int64_t now, const int64_t offline_time, const int64_t kill_time);
   };
   typedef std::shared_ptr<NodeInfo> Node;
   typedef std::weak_ptr<NodeInfo> WeakNode;
@@ -171,6 +174,7 @@
private:
   void CheckNodes();
   bool CanHeartbeat(const NodeInfo &node) { return Valid(node) || node.state_.flag_ == kStateOffline; }
   void Publish(const Topic &topic, const std::string &content);
   bool Valid(const NodeInfo &node) { return node.state_.flag_ == kStateNormal; }
   bool Valid(const WeakNode &weak)
   {