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 46 of file subscription_token.hpp.

Public Types

using OnMessageCb
 
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
Initial value:
std::function<void(const std::string& channel,
const std::string& message)>

Definition at line 48 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 50 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 77 of file subscription_token.hpp.

◆ SetMaxQueueLength()

void storages::redis::SubscriptionToken::SetMaxQueueLength ( size_t length)

There is a MPSC queue inside the connection. This parameter requlates 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: