Merge pull request #26 from tdlight-team/getmemorystats

Added getMemoryStats query
This commit is contained in:
Andrea Cavalli 2020-12-15 12:12:12 +01:00 committed by GitHub
commit 7c642e8e41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 4 deletions

View File

@ -37,8 +37,11 @@ Please note that only TDLight-specific issues are suitable for this repository.
<a name="added-api-methods"></a>
#### Added API Methods
##### Method `optimize_memory`
Calling `optimize_memory` will remove old data from the in-memory cache and give the freed memory back to the os
##### Method `optimizeMemory`
Calling `optimizeMemory` will remove old data from the in-memory cache and give the freed memory back to the os
##### Method `getMemoryStats`
Calling `getMemoryStats` will return a json containing the info about the memory manager, more info [here](https://github.com/tdlight-team/tdlight#tdapigetmemorystatistics)
##### Method `getMessageInfo`
Get information about a message

2
td

@ -1 +1 @@
Subproject commit 2b92c16998d39e7bfee580defcb0109151e4fb81
Subproject commit ec5614fd43c56ba4d6dd7e6a517bc55116ab45cd

View File

@ -295,6 +295,7 @@ bool Client::init_methods() {
methods_.emplace("deletemessages", &Client::process_delete_messages_query);
methods_.emplace("togglegroupinvites", &Client::process_toggle_group_invites_query);
methods_.emplace("ping", &Client::process_ping_query);
methods_.emplace("getmemorystats", &Client::process_get_memory_stats_query);
return true;
@ -3328,6 +3329,26 @@ class Client::TdOnPingCallback : public TdQueryCallback {
PromisedQueryPtr query_;
};
class Client::TdOnGetMemoryStatisticsCallback : public TdQueryCallback {
public:
explicit TdOnGetMemoryStatisticsCallback(PromisedQueryPtr query)
: query_(std::move(query)) {
}
void on_result(object_ptr<td_api::Object> result) override {
if (result->get_id() == td_api::error::ID) {
return fail_query_with_error(std::move(query_), move_object_as<td_api::error>(result));
}
auto res = move_object_as<td_api::memoryStatistics>(result);
answer_query(td::JsonRaw(res->statistics_), std::move(query_));
}
private:
PromisedQueryPtr query_;
};
//end custom callbacks impl
void Client::close() {
@ -7677,8 +7698,13 @@ td::Status Client::process_ping_query(PromisedQueryPtr &query) {
return Status::OK();
}
td::Status Client::process_get_memory_stats_query(PromisedQueryPtr &query) {
send_request(make_object<td_api::getMemoryStatistics>(),
std::make_unique<TdOnGetMemoryStatisticsCallback>(std::move(query)));
return Status::OK();
}
//end custom methods impl
//start costom auth methods impl
//start custom auth methods impl
void Client::process_authcode_query(PromisedQueryPtr &query) {
auto code = query->arg("code");

View File

@ -191,6 +191,7 @@ class Client : public WebhookActor::Callback {
//start custom callbacks
class TdOnPingCallback;
class TdOnGetMemoryStatisticsCallback;
//end custom callbacks
void on_get_reply_message(int64 chat_id, object_ptr<td_api::message> reply_to_message);
@ -508,6 +509,7 @@ class Client : public WebhookActor::Callback {
Status process_delete_messages_query(PromisedQueryPtr &query);
Status process_toggle_group_invites_query(PromisedQueryPtr &query);
Status process_ping_query(PromisedQueryPtr &query);
Status process_get_memory_stats_query(PromisedQueryPtr &query);
//custom auth methods
void process_authcode_query(PromisedQueryPtr &query);