mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-05-08 19:48:42 +00:00
instantiate smee client
This commit is contained in:
parent
d2aeff6752
commit
d71d051c53
@ -21,6 +21,8 @@
|
|||||||
#include "../version.h"
|
#include "../version.h"
|
||||||
#include "Redis.hpp"
|
#include "Redis.hpp"
|
||||||
|
|
||||||
|
#include <smeeclient.h>
|
||||||
|
|
||||||
#include <libpq-fe.h>
|
#include <libpq-fe.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
@ -159,6 +161,8 @@ using Attrs = std::vector<std::pair<std::string, std::string>>;
|
|||||||
using Item = std::pair<std::string, Attrs>;
|
using Item = std::pair<std::string, Attrs>;
|
||||||
using ItemStream = std::vector<Item>;
|
using ItemStream = std::vector<Item>;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PostgreSQL::PostgreSQL(const Identity &myId, const char *path, int listenPort, RedisConfig *rc)
|
PostgreSQL::PostgreSQL(const Identity &myId, const char *path, int listenPort, RedisConfig *rc)
|
||||||
: DB()
|
: DB()
|
||||||
, _pool()
|
, _pool()
|
||||||
@ -173,6 +177,7 @@ PostgreSQL::PostgreSQL(const Identity &myId, const char *path, int listenPort, R
|
|||||||
, _redis(NULL)
|
, _redis(NULL)
|
||||||
, _cluster(NULL)
|
, _cluster(NULL)
|
||||||
, _redisMemberStatus(false)
|
, _redisMemberStatus(false)
|
||||||
|
, _smee(NULL)
|
||||||
{
|
{
|
||||||
char myAddress[64];
|
char myAddress[64];
|
||||||
_myAddressStr = myId.address().toString(myAddress);
|
_myAddressStr = myId.address().toString(myAddress);
|
||||||
@ -248,10 +253,17 @@ PostgreSQL::PostgreSQL(const Identity &myId, const char *path, int listenPort, R
|
|||||||
_commitThread[i] = std::thread(&PostgreSQL::commitThread, this);
|
_commitThread[i] = std::thread(&PostgreSQL::commitThread, this);
|
||||||
}
|
}
|
||||||
_onlineNotificationThread = std::thread(&PostgreSQL::onlineNotificationThread, this);
|
_onlineNotificationThread = std::thread(&PostgreSQL::onlineNotificationThread, this);
|
||||||
|
|
||||||
|
configureSmee();
|
||||||
}
|
}
|
||||||
|
|
||||||
PostgreSQL::~PostgreSQL()
|
PostgreSQL::~PostgreSQL()
|
||||||
{
|
{
|
||||||
|
if (_smee != NULL) {
|
||||||
|
smeeclient::smee_client_delete(_smee);
|
||||||
|
_smee = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
_run = 0;
|
_run = 0;
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
|
|
||||||
@ -265,6 +277,20 @@ PostgreSQL::~PostgreSQL()
|
|||||||
_onlineNotificationThread.join();
|
_onlineNotificationThread.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PostgreSQL::configureSmee()
|
||||||
|
{
|
||||||
|
const char *TEMPORAL_HOST = "ZT_TEMPORAL_HOST";
|
||||||
|
const char *TEMPORAL_NAMESPACE = "ZT_TEMPORAL_NAMESPACE";
|
||||||
|
const char *SMEE_TASK_QUEUE = "ZT_SMEE_TASK_QUEUE";
|
||||||
|
|
||||||
|
const char *host = getenv(TEMPORAL_HOST);
|
||||||
|
const char *ns = getenv(TEMPORAL_NAMESPACE);
|
||||||
|
const char *task_queue = getenv(SMEE_TASK_QUEUE);
|
||||||
|
|
||||||
|
if (host != NULL && ns != NULL && task_queue != NULL) {
|
||||||
|
this->_smee = smeeclient::smee_client_new(host, ns, task_queue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool PostgreSQL::waitForReady()
|
bool PostgreSQL::waitForReady()
|
||||||
{
|
{
|
||||||
|
@ -32,6 +32,10 @@ extern "C" {
|
|||||||
typedef struct pg_conn PGconn;
|
typedef struct pg_conn PGconn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace smeeclient {
|
||||||
|
struct SmeeClient;
|
||||||
|
}
|
||||||
|
|
||||||
namespace ZeroTier {
|
namespace ZeroTier {
|
||||||
|
|
||||||
struct RedisConfig;
|
struct RedisConfig;
|
||||||
@ -144,6 +148,8 @@ private:
|
|||||||
uint64_t _doRedisUpdate(sw::redis::Transaction &tx, std::string &controllerId,
|
uint64_t _doRedisUpdate(sw::redis::Transaction &tx, std::string &controllerId,
|
||||||
std::unordered_map< std::pair<uint64_t,uint64_t>,std::pair<int64_t,InetAddress>,_PairHasher > &lastOnline);
|
std::unordered_map< std::pair<uint64_t,uint64_t>,std::pair<int64_t,InetAddress>,_PairHasher > &lastOnline);
|
||||||
|
|
||||||
|
void configureSmee();
|
||||||
|
|
||||||
enum OverrideMode {
|
enum OverrideMode {
|
||||||
ALLOW_PGBOUNCER_OVERRIDE = 0,
|
ALLOW_PGBOUNCER_OVERRIDE = 0,
|
||||||
NO_OVERRIDE = 1
|
NO_OVERRIDE = 1
|
||||||
@ -178,6 +184,8 @@ private:
|
|||||||
std::shared_ptr<sw::redis::Redis> _redis;
|
std::shared_ptr<sw::redis::Redis> _redis;
|
||||||
std::shared_ptr<sw::redis::RedisCluster> _cluster;
|
std::shared_ptr<sw::redis::RedisCluster> _cluster;
|
||||||
bool _redisMemberStatus;
|
bool _redisMemberStatus;
|
||||||
|
|
||||||
|
smeeclient::SmeeClient *_smee;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ZeroTier
|
} // namespace ZeroTier
|
||||||
|
@ -326,9 +326,9 @@ ifeq ($(ZT_CONTROLLER),1)
|
|||||||
override DEFS+=-DZT_CONTROLLER_USE_LIBPQ -DZT_NO_PEER_METRICS
|
override DEFS+=-DZT_CONTROLLER_USE_LIBPQ -DZT_NO_PEER_METRICS
|
||||||
override INCLUDES+=-I/usr/include/postgresql -Iext/libpqxx-7.7.3/install/ubuntu22.04/$(EXT_ARCH)/include -Iext/hiredis-1.0.2/include/ -Iext/redis-plus-plus-1.3.3/install/ubuntu22.04/$(EXT_ARCH)/include/sw/
|
override INCLUDES+=-I/usr/include/postgresql -Iext/libpqxx-7.7.3/install/ubuntu22.04/$(EXT_ARCH)/include -Iext/hiredis-1.0.2/include/ -Iext/redis-plus-plus-1.3.3/install/ubuntu22.04/$(EXT_ARCH)/include/sw/
|
||||||
ifeq ($(ZT_DEBUG),1)
|
ifeq ($(ZT_DEBUG),1)
|
||||||
LDLIBS+=rustybits/target/debug/libsmeeclient.a -ldl -lssl -lcrypto
|
override LDLIBS+=rustybits/target/debug/libsmeeclient.a
|
||||||
else
|
else
|
||||||
LDLIBS+=rustybits/target/release/libsmeeclient.a -ldl -lssl -lcrypto
|
override LDLIBS+=rustybits/target/release/libsmeeclient.a
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user