userver: storages::redis::SubscribeClient Class Reference
Loading...
Searching...
No Matches
storages::redis::SubscribeClient Class Referenceabstract

Client that allows subscribing to Redis channel messages. More...

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

Public Member Functions

virtual SubscriptionToken Subscribe (std::string channel, SubscriptionToken::OnMessageCb on_message_cb, const ::redis::CommandControl &command_control)=0
 
SubscriptionToken Subscribe (std::string channel, SubscriptionToken::OnMessageCb on_message_cb)
 
virtual SubscriptionToken Psubscribe (std::string pattern, SubscriptionToken::OnPmessageCb on_pmessage_cb, const ::redis::CommandControl &command_control)=0
 
SubscriptionToken Psubscribe (std::string pattern, SubscriptionToken::OnPmessageCb on_pmessage_cb)
 

Detailed Description

Client that allows subscribing to Redis channel messages.

Usually retrieved from components::Redis component.

Callback for each received message is called only after the execution of callback for previous message has finished. For parallel message processing use the utils::Async().

Warning
Messages can be received in any order due to Redis sharding. Sometimes messages can be duplicated due to subscriptions rebalancing. Some messages may be lost (it's a Redis limitation).
The first callback execution can happen before Subscribe() or Psubscribe() return as it happens in a separate task.
Note
a good GMock-based mock for this class can be found here: userver/storages/redis/mock_subscribe_client.hpp

Definition at line 42 of file subscribe_client.hpp.

Member Function Documentation

◆ Psubscribe()

SubscriptionToken storages::redis::SubscribeClient::Psubscribe ( std::string  pattern,
SubscriptionToken::OnPmessageCb  on_pmessage_cb 
)
inline

Definition at line 59 of file subscribe_client.hpp.

◆ Subscribe()

SubscriptionToken storages::redis::SubscribeClient::Subscribe ( std::string  channel,
SubscriptionToken::OnMessageCb  on_message_cb 
)
inline

Definition at line 50 of file subscribe_client.hpp.


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