/*
 * @Description: 
 * @Version: 1.0
 * @Autor: lishengyin
 * @Date: 2022-04-06 17:07:02
 * @LastEditors: lishengyin
 * @LastEditTime: 2022-06-21 16:57:55
 */
#ifndef __DISPOSITION_HPP_
#define __DISPOSITION_HPP_

#include <iostream>
#include "ins_base.hpp"

#include "Util/util.h"
#include "Util/logger.h"
#include "Util/TimeTicker.h"
#include "Poller/Timer.h"
#include "dataTypeList.hpp"

using namespace std;
using namespace toolkit;

namespace ins
{   
    class Disposition:public Module
    {
    private:
        Disposition():Module("Disposition"){
            Init();
        }
        
    public:
        using Ptr = std::shared_ptr<Disposition>;

        ~Disposition(){this->Destroy();}

        /**
         * @description: 初始化
         * @param {*}
         * @return {*}
         */        
        int8_t Init() override{
            if(this->valid) return OK;
            // 定时更新数据
            if(timer == nullptr) this->timer = std::make_shared<Timer>(2.0f, [&](){
                return true;
            },nullptr);
            this->valid = true;
            return OK;
        }
        
        /**
         * @description: 释放资源
         * @param {*}
         * @return {*}
         */        
        void Destroy() override;

        /**
         * @description: 获取ptr
         * @param {*}
         * @return {*}
         */        
        static std::shared_ptr<Disposition> getPtr();

        /**
         * @description: 是否正常
         * @param {*}
         * @return {*}
         */        
        bool isNormally() override{
            return true;
        } 

        /**
         * @description: 获取USERID
         * @param {*}
         * @return {*}
         */        
        int getUserId();

        /**
         * @description: 更新任务
         * @param {*}
         * @return {*}
         */        
        bool Update();

        /**
         * @description: 获取token
         * @return {*}
         */        
        bool getKsToken(){
            if(KsToken.access_token == "") return false;
            else return true;
        }

        /**
         * @description: 获取工作区间
         * @return {*}
         */        
        std::string getWorkspace(){
            return workspace;
        }
    
    public:
        std::string k8s_IP = "192.168.31.73";
        int k8s_port = 31385;
        
        std::string netty_IP;
        int netty_port;

        std::string mysql_IP = "192.168.31.97";
        int mysql_port = 13306;

        std::string apollo_IP = "192.168.31.97";
        int apollo_port = 8080;
        int ayncThreadNum = 4;
        int serverPort = 8111;

        KubusphrereToken KsToken;
    private:
        Timer::Ptr timer = nullptr;
        std::string usr = "admin2";
        std::string workspace = "system-base";
    };

} // namespace ins

#endif