#include <userver/storages/redis/subscription_token.hpp>
RAII subscription guard, that is usually retrieved from storages::redis::SubscribeClient.
See storages::redis::MockSubscriptionTokenImpl for hints on mocking and testing.
Definition at line 45 of file subscription_token.hpp.
Public Types | |
using | OnMessageCb = std::function<void(const std::string& channel, const std::string& message)> |
using | OnPmessageCb |
Public Member Functions | |
SubscriptionToken (SubscriptionToken &&) noexcept | |
SubscriptionToken (std::unique_ptr< impl::SubscriptionTokenImplBase > &&implementation) | |
SubscriptionToken & | operator= (SubscriptionToken &&) noexcept |
void | SetMaxQueueLength (size_t length) |
void | Unsubscribe () |
bool | IsEmpty () const noexcept |
using storages::redis::SubscriptionToken::OnMessageCb = std::function<void(const std::string& channel, const std::string& message)> |
Definition at line 47 of file subscription_token.hpp.
using storages::redis::SubscriptionToken::OnPmessageCb |
Definition at line 48 of file subscription_token.hpp.
storages::redis::SubscriptionToken::SubscriptionToken | ( | std::unique_ptr< impl::SubscriptionTokenImplBase > && | implementation | ) |
This constructor can be used in tests/mocks to create your own subscription token
|
inlinenoexcept |
Checks that token is not empty. Empty token has no implementation inside. This method is mostly useful in unit tests. All methods of this class work correctly on empty tokens.
Definition at line 73 of file subscription_token.hpp.
void storages::redis::SubscriptionToken::SetMaxQueueLength | ( | size_t | length | ) |
There is a MPSC queue inside the connection. This parameter regulates its maximum length. If it overflows, new messages are discarded.
void storages::redis::SubscriptionToken::Unsubscribe | ( | ) |
Unsubscribe from the channel. This method is synchronous, once it returned, no new calls to callback will be made.