many different fixes
This commit is contained in:
1 parent
b4073ddf1e
commit
5e1e3d66c4
8 files changed
+116
-59
No files matched your search
@@ -7,6 +7,9 @@
|
||||
#include <optional>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <shared_mutex>
|
||||
#include <atomic>
|
||||
|
||||
namespace Echoion::Api {
|
||||
|
||||
@@ -160,21 +163,31 @@ public:
|
||||
|
||||
// ===== Subscriptions =====
|
||||
|
||||
// Add a subscriber
|
||||
Api::Result<void> addSubscriber(uint64_t clientId);
|
||||
// Subscriber info
|
||||
struct SubscriberInfo {
|
||||
std::string uid;
|
||||
std::string nickname;
|
||||
std::chrono::system_clock::time_point subscribedAt;
|
||||
};
|
||||
|
||||
// Remove a subscriber
|
||||
Api::Result<void> removeSubscriber(uint64_t clientId);
|
||||
// Add a subscriber (by UID)
|
||||
Api::Result<void> addSubscriber(const std::string& uid, const std::string& nickname);
|
||||
|
||||
// Check if client is subscribed
|
||||
[[nodiscard]] Api::Result<bool> isSubscriber(uint64_t clientId);
|
||||
// Remove a subscriber (by UID)
|
||||
Api::Result<void> removeSubscriber(const std::string& uid);
|
||||
|
||||
// Check if client is subscribed (by UID)
|
||||
[[nodiscard]] Api::Result<bool> isSubscriber(const std::string& uid);
|
||||
|
||||
// Get all subscribers
|
||||
[[nodiscard]] Api::Result<std::vector<uint64_t>> getAllSubscribers();
|
||||
[[nodiscard]] Api::Result<std::vector<SubscriberInfo>> getAllSubscribers();
|
||||
|
||||
// Get subscriber count
|
||||
[[nodiscard]] Api::Result<size_t> getSubscriberCount();
|
||||
|
||||
// Clear all subscribers
|
||||
Api::Result<void> clearAllSubscribers();
|
||||
|
||||
// ===== Cache Management =====
|
||||
|
||||
// Clear old history (keep last N entries)
|
||||
@@ -193,6 +206,8 @@ public:
|
||||
|
||||
private:
|
||||
std::unique_ptr<DatabaseImpl> impl_;
|
||||
mutable std::shared_mutex mutex_; // Shared mutex for read/write concurrency
|
||||
std::atomic<bool> shutdown_{false}; // Flag to prevent operations after shutdown
|
||||
};
|
||||
|
||||
// Database manager (singleton)
|
||||
|
||||
Reference in new issue
Block a user