Disposition.hpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * @Description:
  3. * @Version: 1.0
  4. * @Autor: lishengyin
  5. * @Date: 2022-04-06 17:07:02
  6. * @LastEditors: lishengyin
  7. * @LastEditTime: 2022-06-21 16:57:55
  8. */
  9. #ifndef __DISPOSITION_HPP_
  10. #define __DISPOSITION_HPP_
  11. #include <iostream>
  12. #include "ins_base.hpp"
  13. #include "Util/util.h"
  14. #include "Util/logger.h"
  15. #include "Util/TimeTicker.h"
  16. #include "Poller/Timer.h"
  17. #include "dataTypeList.hpp"
  18. using namespace std;
  19. using namespace toolkit;
  20. namespace ins
  21. {
  22. class Disposition:public Module
  23. {
  24. private:
  25. Disposition():Module("Disposition"){
  26. Init();
  27. }
  28. public:
  29. using Ptr = std::shared_ptr<Disposition>;
  30. ~Disposition(){this->Destroy();}
  31. /**
  32. * @description: 初始化
  33. * @param {*}
  34. * @return {*}
  35. */
  36. int8_t Init() override{
  37. if(this->valid) return OK;
  38. // 定时更新数据
  39. if(timer == nullptr) this->timer = std::make_shared<Timer>(2.0f, [&](){
  40. return true;
  41. },nullptr);
  42. this->valid = true;
  43. return OK;
  44. }
  45. /**
  46. * @description: 释放资源
  47. * @param {*}
  48. * @return {*}
  49. */
  50. void Destroy() override;
  51. /**
  52. * @description: 获取ptr
  53. * @param {*}
  54. * @return {*}
  55. */
  56. static std::shared_ptr<Disposition> getPtr();
  57. /**
  58. * @description: 是否正常
  59. * @param {*}
  60. * @return {*}
  61. */
  62. bool isNormally() override{
  63. return true;
  64. }
  65. /**
  66. * @description: 获取USERID
  67. * @param {*}
  68. * @return {*}
  69. */
  70. int getUserId();
  71. /**
  72. * @description: 更新任务
  73. * @param {*}
  74. * @return {*}
  75. */
  76. bool Update();
  77. /**
  78. * @description: 获取token
  79. * @return {*}
  80. */
  81. bool getKsToken(){
  82. if(KsToken.access_token == "") return false;
  83. else return true;
  84. }
  85. /**
  86. * @description: 获取工作区间
  87. * @return {*}
  88. */
  89. std::string getWorkspace(){
  90. return workspace;
  91. }
  92. public:
  93. std::string k8s_IP = "192.168.31.73";
  94. int k8s_port = 31385;
  95. std::string netty_IP;
  96. int netty_port;
  97. std::string mysql_IP = "192.168.31.97";
  98. int mysql_port = 13306;
  99. std::string apollo_IP = "192.168.31.97";
  100. int apollo_port = 8080;
  101. int ayncThreadNum = 4;
  102. int serverPort = 8111;
  103. KubusphrereToken KsToken;
  104. private:
  105. Timer::Ptr timer = nullptr;
  106. std::string usr = "admin2";
  107. std::string workspace = "system-base";
  108. };
  109. } // namespace ins
  110. #endif