// // Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023 // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #pragma once #include "td/db/KeyValueSyncInterface.h" #include "td/db/TQueue.h" #include "td/net/GetHostByNameActor.h" #include "td/actor/actor.h" #include "td/utils/common.h" #include "td/utils/List.h" #include "td/utils/port/IPAddress.h" #include #include #include namespace td { class NetQueryStats; } // namespace td namespace telegram_bot_api { struct SharedData { std::atomic query_count_{0}; std::atomic query_list_size_{0}; std::atomic next_verbosity_level_{-1}; // not thread-safe, must be used from a single thread td::ListNode query_list_; td::unique_ptr webhook_db_; td::unique_ptr user_db_; td::unique_ptr tqueue_; double unix_time_difference_{-1e100}; static constexpr size_t TQUEUE_EVENT_BUFFER_SIZE = 1000; td::TQueue::Event event_buffer_[TQUEUE_EVENT_BUFFER_SIZE]; td::int32 get_unix_time(double now) const { auto result = unix_time_difference_ + now; if (result <= 0) { return 0; } if (result >= std::numeric_limits::max()) { return std::numeric_limits::max(); } return static_cast(result); } static td::int32 get_database_scheduler_id() { // the same scheduler as for database in Td return 1; } static td::int32 get_file_gc_scheduler_id() { // the same scheduler as for file GC in Td return 2; } }; struct ClientParameters { td::string working_directory_; bool allow_colon_in_filenames_ = true; bool local_mode_ = false; bool allow_http_ = false; bool use_relative_path_ = false; bool no_file_limit_ = true; bool allow_users_ = false; bool allow_users_registration_ = false; bool stats_hide_sensible_data_ = false; td::int32 api_id_ = 0; td::string api_hash_; td::string version_; td::int32 default_max_webhook_connections_ = 0; td::IPAddress webhook_proxy_ip_address_; td::uint32 max_batch_operations = 10000; double start_time_ = 0; td::int32 file_expiration_timeout_seconds_ = 3600; td::ActorId get_host_by_name_actor_id_; std::shared_ptr shared_data_; std::shared_ptr net_query_stats_; }; } // namespace telegram_bot_api