10USERVER_NAMESPACE_BEGIN
14class SubscribeSentinel;
21class SubscriptionTokenImplBase {
23 SubscriptionTokenImplBase() =
default;
25 SubscriptionTokenImplBase(SubscriptionTokenImplBase&&) =
delete;
26 SubscriptionTokenImplBase& operator=(SubscriptionTokenImplBase&&) =
delete;
28 SubscriptionTokenImplBase(
const SubscriptionTokenImplBase&) =
delete;
29 SubscriptionTokenImplBase& operator=(
const SubscriptionTokenImplBase&&) =
32 virtual ~SubscriptionTokenImplBase();
34 virtual void SetMaxQueueLength(size_t length) = 0;
36 virtual void Unsubscribe() = 0;
46class [[nodiscard]] SubscriptionToken
final {
48 using OnMessageCb = std::function<
void(
const std::string& channel,
49 const std::string& message)>;
51 std::function<
void(
const std::string& pattern,
const std::string& channel,
52 const std::string& message)>;
55 SubscriptionToken(SubscriptionToken&&)
noexcept;
60 std::unique_ptr<impl::SubscriptionTokenImplBase>&& implementation);
64 SubscriptionToken& operator=(SubscriptionToken&&)
noexcept;
77 bool IsEmpty()
const noexcept {
return impl_ ==
nullptr; }
80 std::unique_ptr<impl::SubscriptionTokenImplBase> impl_;