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

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

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 37 of file subscribe_client.hpp.

Public Member Functions

virtual SubscriptionToken Subscribe (std::string channel, SubscriptionToken::OnMessageCb on_message_cb, const 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 CommandControl &command_control)=0
virtual size_t ShardsCount () const =0
virtual bool IsInClusterMode () const =0
virtual bool IsReady (const HealthCheckParams &params) const =0
bool IsReady (WaitConnectedMode mode) const
SubscriptionToken Psubscribe (std::string pattern, SubscriptionToken::OnPmessageCb on_pmessage_cb)
virtual SubscriptionToken Ssubscribe (std::string channel, SubscriptionToken::OnMessageCb on_message_cb, const CommandControl &command_control)=0
virtual SubscriptionToken Subscribe (std::vector< std::string > channels, SubscriptionToken::OnMessageCb on_message_cb, const CommandControl &command_control)=0
virtual SubscriptionToken Psubscribe (std::vector< std::string > patterns, SubscriptionToken::OnPmessageCb on_message_cb, const CommandControl &command_control)=0
virtual SubscriptionToken Ssubscribe (std::vector< std::string > channels, SubscriptionToken::OnMessageCb on_message_cb, const CommandControl &command_control)=0
SubscriptionToken Ssubscribe (std::string channel, SubscriptionToken::OnMessageCb on_message_cb)
SubscriptionToken Ssubscribe (std::vector< std::string > channels, SubscriptionToken::OnMessageCb on_message_cb)
SubscriptionToken Psubscribe (std::vector< std::string > patterns, SubscriptionToken::OnPmessageCb on_message_cb)

Member Function Documentation

◆ IsReady()

bool storages::redis::SubscribeClient::IsReady ( WaitConnectedMode mode) const
inline

Definition at line 61 of file subscribe_client.hpp.

◆ Psubscribe() [1/3]

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

Definition at line 63 of file subscribe_client.hpp.

◆ Psubscribe() [2/3]

SubscriptionToken storages::redis::SubscribeClient::Psubscribe ( std::vector< std::string > patterns,
SubscriptionToken::OnPmessageCb on_message_cb )
inline

Definition at line 103 of file subscribe_client.hpp.

◆ Psubscribe() [3/3]

virtual SubscriptionToken storages::redis::SubscribeClient::Psubscribe ( std::vector< std::string > patterns,
SubscriptionToken::OnPmessageCb on_message_cb,
const CommandControl & command_control )
pure virtual

Retrieves a single subscription token for multiple channels. Uses a single coroutine to handle messages from all channels.

◆ Ssubscribe() [1/3]

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

Definition at line 95 of file subscribe_client.hpp.

◆ Ssubscribe() [2/3]

SubscriptionToken storages::redis::SubscribeClient::Ssubscribe ( std::vector< std::string > channels,
SubscriptionToken::OnMessageCb on_message_cb )
inline

Definition at line 99 of file subscribe_client.hpp.

◆ Ssubscribe() [3/3]

virtual SubscriptionToken storages::redis::SubscribeClient::Ssubscribe ( std::vector< std::string > channels,
SubscriptionToken::OnMessageCb on_message_cb,
const CommandControl & command_control )
pure virtual

Retrieves a single subscription token for multiple channels. Uses a single coroutine to handle messages from all channels.

◆ Subscribe() [1/2]

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

Definition at line 47 of file subscribe_client.hpp.

◆ Subscribe() [2/2]

virtual SubscriptionToken storages::redis::SubscribeClient::Subscribe ( std::vector< std::string > channels,
SubscriptionToken::OnMessageCb on_message_cb,
const CommandControl & command_control )
pure virtual

Retrieves a single subscription token for multiple channels. Uses a single coroutine to handle messages from all channels.


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