userver: storages::redis::SubscriptionToken Class Reference
Loading...
Searching...
No Matches
storages::redis::SubscriptionToken Class Referencefinal

#include <userver/storages/redis/subscription_token.hpp>

Detailed Description

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)
 
SubscriptionTokenoperator= (SubscriptionToken &&) noexcept
 
void SetMaxQueueLength (size_t length)
 
void Unsubscribe ()
 
bool IsEmpty () const noexcept
 

Member Typedef Documentation

◆ OnMessageCb

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.

◆ OnPmessageCb

using storages::redis::SubscriptionToken::OnPmessageCb
Initial value:
std::function<void(const std::string& pattern, const std::string& channel, const std::string& message)>

Definition at line 48 of file subscription_token.hpp.

Constructor & Destructor Documentation

◆ SubscriptionToken()

storages::redis::SubscriptionToken::SubscriptionToken ( std::unique_ptr< impl::SubscriptionTokenImplBase > && implementation)

This constructor can be used in tests/mocks to create your own subscription token

Member Function Documentation

◆ IsEmpty()

bool storages::redis::SubscriptionToken::IsEmpty ( ) const
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.

◆ SetMaxQueueLength()

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.

◆ Unsubscribe()

void storages::redis::SubscriptionToken::Unsubscribe ( )

Unsubscribe from the channel. This method is synchronous, once it returned, no new calls to callback will be made.


The documentation for this class was generated from the following file: