Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions include/atframe/atapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ ATBUS_MACRO_NAMESPACE_END
LIBATAPP_MACRO_NAMESPACE_BEGIN

class etcd_module;
class service_discovery_module;
class worker_pool_module;
class atapp_connector_atbus;
class atapp_connector_loopback;
struct LIBATAPP_MACRO_API curl_multi_guard_type;

class app {
public:
Expand Down Expand Up @@ -394,7 +396,8 @@ class app {

LIBATAPP_MACRO_API void pack(atapp::protocol::atapp_discovery &out) const;

LIBATAPP_MACRO_API const std::shared_ptr<::atframework::atapp::etcd_module> &get_etcd_module() const noexcept;
LIBATAPP_MACRO_API const std::shared_ptr<::atframework::atapp::service_discovery_module> &
get_service_discovery_module() const noexcept;

Comment thread
yousongyang marked this conversation as resolved.
LIBATAPP_MACRO_API const std::shared_ptr<::atframework::atapp::worker_pool_module> &get_worker_pool_module()
const noexcept;
Expand Down Expand Up @@ -601,6 +604,8 @@ class app {

int setup_atbus();

int setup_curl_multi();

static void close_timer(timer_ptr_t &t);

int setup_tick_timer();
Expand Down Expand Up @@ -663,8 +668,8 @@ class app {
int command_handler_stop(atfw::util::cli::callback_param params);
int command_handler_reload(atfw::util::cli::callback_param params);
int command_handler_invalid(atfw::util::cli::callback_param params);
int command_handler_disable_etcd(atfw::util::cli::callback_param params);
int command_handler_enable_etcd(atfw::util::cli::callback_param params);
int command_handler_disable_discovery(atfw::util::cli::callback_param params);
int command_handler_enable_discovery(atfw::util::cli::callback_param params);
int command_handler_list_discovery(atfw::util::cli::callback_param params);

private:
Expand Down Expand Up @@ -786,9 +791,12 @@ class app {
};
stats_data_t stats_;

std::shared_ptr<curl_multi_guard_type> curl_multi_guard_;
atfw::util::network::http_request::curl_m_bind_ptr_t curl_multi_;

// inner modules
std::shared_ptr<::atframework::atapp::worker_pool_module> internal_module_worker_pool_;
std::shared_ptr<::atframework::atapp::etcd_module> internal_module_etcd_;
std::shared_ptr<::atframework::atapp::service_discovery_module> internal_module_service_discovery_;
etcd_discovery_set internal_empty_discovery_set_;

// inner endpoints
Expand Down
9 changes: 6 additions & 3 deletions include/atframe/atapp_conf.proto
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,10 @@ message atapp_etcd_cluster {
}

message atapp_etcd_keepalive {
google.protobuf.Duration timeout = 1 [(atapp.protocol.CONFIGURE) = { default_value: "31s" }];
google.protobuf.Duration ttl = 2 [(atapp.protocol.CONFIGURE) = { default_value: "10s" }];
google.protobuf.Duration retry_interval = 3 [(atapp.protocol.CONFIGURE) = { default_value: "3s" }];
bool enabled = 1 [(atapp.protocol.CONFIGURE) = { default_value: "true" }];
google.protobuf.Duration timeout = 101 [(atapp.protocol.CONFIGURE) = { default_value: "31s" }];
google.protobuf.Duration ttl = 102 [(atapp.protocol.CONFIGURE) = { default_value: "10s" }];
google.protobuf.Duration retry_interval = 103 [(atapp.protocol.CONFIGURE) = { default_value: "3s" }];
Comment thread
yousongyang marked this conversation as resolved.
Comment thread
yousongyang marked this conversation as resolved.
Comment thread
owent marked this conversation as resolved.
Comment thread
yousongyang marked this conversation as resolved.
}
Comment on lines +411 to 415

message atapp_etcd_request {
Expand All @@ -428,6 +429,7 @@ message atapp_etcd_init {
}

message atapp_etcd_watcher {
bool enabled = 1 [(atapp.protocol.CONFIGURE) = { default_value: "true" }];
google.protobuf.Duration retry_interval = 101 [(atapp.protocol.CONFIGURE) = { default_value: "15s" }];
google.protobuf.Duration request_timeout = 102 [(atapp.protocol.CONFIGURE) = { default_value: "30m" }];
google.protobuf.Duration get_request_timeout = 103 [(atapp.protocol.CONFIGURE) = { default_value: "3m" }];
Expand Down Expand Up @@ -593,6 +595,7 @@ message atapp_configure {
atbus_configure bus = 301;

atapp_etcd etcd = 401;
repeated atapp_etcd external_discovery = 402;

atapp_worker_pool worker_pool = 501;
}
Expand Down
5 changes: 4 additions & 1 deletion include/atframe/etcdcli/etcd_discovery.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ class etcd_discovery_node {
ATFW_UTIL_FORCEINLINE const atapp::protocol::atapp_discovery &get_discovery_info() const { return node_info_; }
ATFW_UTIL_FORCEINLINE const node_version &get_version() const noexcept { return node_version_; }

LIBATAPP_MACRO_API void copy_from(const atapp::protocol::atapp_discovery &input, const node_version &version);
LIBATAPP_MACRO_API void copy_from(const atapp::protocol::atapp_discovery &input, const node_version &version,
uintptr_t context_addr);
Comment thread
yousongyang marked this conversation as resolved.
LIBATAPP_MACRO_API void update_version(const node_version &version, bool upgrade);
LIBATAPP_MACRO_API void copy_to(atapp::protocol::atapp_discovery &output) const;
LIBATAPP_MACRO_API void copy_key_to(atapp::protocol::atapp_discovery &output) const;
LIBATAPP_MACRO_API uintptr_t get_context_addr() const noexcept { return context_addr_; }

ATFW_UTIL_FORCEINLINE const std::pair<uint64_t, uint64_t> &get_name_hash() const noexcept { return name_hash_; }

Expand All @@ -78,6 +80,7 @@ class etcd_discovery_node {
private:
atapp::protocol::atapp_discovery node_info_;
node_version node_version_;
uintptr_t context_addr_;

std::pair<uint64_t, uint64_t> name_hash_;
union {
Expand Down
Loading
Loading