wsproxy/server/wsproxy/upstreammgr.h
aozhiwei 39e1c883b6 1
2023-04-24 11:08:56 +08:00

26 lines
620 B
C++

#pragma once
#include <a8/singleton.h>
class UpStream;
class UpStreamMgr : public a8::Singleton<UpStreamMgr>
{
private:
UpStreamMgr() {};
friend class a8::Singleton<UpStreamMgr>;
public:
void Init();
void UnInit();
std::weak_ptr<UpStream> GetUpStreamByKey(const std::string& key);
std::weak_ptr<UpStream> GetUpStreamById(int instance_id);
std::weak_ptr<UpStream> RecreateUpStream(const std::string& host, int port);
private:
unsigned short curr_id_ = 1000;
std::map<std::string, std::shared_ptr<UpStream>> key_hash_;
std::map<int, std::shared_ptr<UpStream>> id_hash_;
};