Logo RedisPubSub Project   v0.9.0
RedisPubSub is an utility with Publisher/Subscirber model based on Redis for J-PARC/MLF.
RedisSyncSubscriber Class Reference

Synchronous subscriber using Redis Publisher/Subscriber Package. More...

#include <RedisPubSub.h>

Inheritance diagram for RedisSyncSubscriber:
Collaboration diagram for RedisSyncSubscriber:

Public Member Functions

 RedisSyncSubscriber ()
 Default constructor. More...
 
 RedisSyncSubscriber (const string &host, int32_t port=6379)
 Constructor. More...
 
virtual ~RedisSyncSubscriber ()
 Destructor. More...
 
int32_t init ()
 Initialize subscriber as synchronous mode and connect to the broker. More...
 
int32_t subscribe (const string &name)
 Subscribe data from the Redis broker (sync). More...
 
int32_t unsubscribe (const string &name)
 Unsubscribe data from the Redis broker (sync). More...
 
int32_t get (string &name, char *target_buf, int32_t &size, int32_t timeout=2000)
 Get data from the Redis broker (sync). More...
 
int32_t getChannels (string name, vector< string > &vec)
 Get name of channels from the Redis broker (sync). More...
 
void setHost (const string &host, int32_t port)
 Set host address of the broker. More...
 

Protected Attributes

string m_host
 
int32_t m_port
 Host IP address. More...
 
std::shared_ptr< redisContext > m_context
 Port number. More...
 

Detailed Description

Synchronous subscriber using Redis Publisher/Subscriber Package.

RedisSyncSubscriber() inherits from RedisSubscriber() and subscribes data in Redis server(broker).

Constructor & Destructor Documentation

RedisSyncSubscriber::RedisSyncSubscriber ( )

Default constructor.

RedisSyncSubscriber::RedisSyncSubscriber ( const string &  host,
int32_t  port = 6379 
)

Constructor.

Parameters
[in]hostHost IP address of the broker.
[in]portPort number of the broker.
RedisSyncSubscriber::~RedisSyncSubscriber ( )
virtual

Destructor.

Member Function Documentation

int32_t RedisSyncSubscriber::get ( string &  name,
char *  target_buf,
int32_t &  size,
int32_t  timeout = 2000 
)

Get data from the Redis broker (sync).

Parameters
[out]nameName of data
[out]target_bufTarget buffer
[out]sizeSize of data
[in]timeoutTimeout milli-seconds
Return values
1Time out
0Success
-1no Redis context(empty)
-2redisSetTimeout() error
-3Redis reply context was null
-4Redis reply error

< replace the object

Here is the caller graph for this function:

int32_t RedisSyncSubscriber::getChannels ( string  name,
vector< string > &  vec 
)

Get name of channels from the Redis broker (sync).

This method should be called before subscribe() or after unsubscribe().

Parameters
[in]nameName of data(allow asterisk like ml*)
[out]veclist of the name
Return values
0Success
-1no Redis context(empty)
-2redisCommand was not executed correctly
-3redisCommand error

Here is the caller graph for this function:

int32_t RedisSyncSubscriber::init ( )

Initialize subscriber as synchronous mode and connect to the broker.

Return values
0Success
-1Redis context was not allocated
-2Redis context has some error condition

Here is the caller graph for this function:

void RedisSubscriber::setHost ( const string &  host,
int32_t  port 
)
inherited

Set host address of the broker.

Parameters
[in]hostHost IP address of the broker.
[in]portPort number of the broker.
int32_t RedisSyncSubscriber::subscribe ( const string &  name)

Subscribe data from the Redis broker (sync).

Parameters
[in]nameName of data
Return values
0Success
-1no Redis context(empty)
-2redisCommand was not executed correctly
-3redisCommand error

Here is the caller graph for this function:

int32_t RedisSyncSubscriber::unsubscribe ( const string &  name)

Unsubscribe data from the Redis broker (sync).

Parameters
[in]nameName of data
Return values
0Success
-1no Redis context(empty)
-2redisCommand was not executed correctly
-3redisCommand error

Here is the caller graph for this function:

Field Documentation

std::shared_ptr<redisContext> RedisSubscriber::m_context
protectedinherited

Port number.

string RedisSubscriber::m_host
protectedinherited
int32_t RedisSubscriber::m_port
protectedinherited

Host IP address.


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