libmoost
moost::psql::pgq_consumer Class Reference

This class represents a consumer for a queue in pgq. More...

#include <pgq.hpp>

List of all members.

Public Member Functions

 pgq_consumer (std::string const &dbconn, std::string const &queue_name, std::string const &consumer_name)
bool register_consumer () const
 Register as a consumer with pgq.
bool unregister_consumer () const
 Unregister the consumer.
bool is_registered () const
 Check whether consumer is currently registered.
template<class FunctorType >
void poll (char const *columns, FunctorType const &functor) const
 Poll the pgq queue and call a functor with the pqxx::result object.
std::string const & dbconn () const
std::string const & queue_name () const
std::string const & consumer_name () const

Private Attributes

std::string const m_dbconn
std::string const m_queue_name
std::string const m_consumer_name

Detailed Description

This class represents a consumer for a queue in pgq.

Definition at line 41 of file pgq.hpp.


Constructor & Destructor Documentation

moost::psql::pgq_consumer::pgq_consumer ( std::string const &  dbconn,
std::string const &  queue_name,
std::string const &  consumer_name 
) [inline]
Parameters:
dbconnthe postgres db connection specification
queue_namethe name of the queue in pgq
consumer_namethe name under which this pgq_consumer object shall register

Definition at line 49 of file pgq.hpp.


Member Function Documentation

std::string const& moost::psql::pgq_consumer::consumer_name ( ) const [inline]
Returns:
The name of this pgq consumer.

Definition at line 221 of file pgq.hpp.

std::string const& moost::psql::pgq_consumer::dbconn ( ) const [inline]
Returns:
The db connection string.

Definition at line 203 of file pgq.hpp.

Check whether consumer is currently registered.

This method connects to the database to check whether the consumer is registered with pgq.

Returns:
Boolean that indicates whether the consumer is currently registered

Definition at line 137 of file pgq.hpp.

template<class FunctorType >
void moost::psql::pgq_consumer::poll ( char const *  columns,
FunctorType const &  functor 
) const [inline]

Poll the pgq queue and call a functor with the pqxx::result object.

This method connects to the database and polls the pgq queue. As long as it receives non-empty results, it calls a functor with a result set.

Parameters:
functorThe functor to be called for each pqxx::result object.

Definition at line 161 of file pgq.hpp.

std::string const& moost::psql::pgq_consumer::queue_name ( ) const [inline]
Returns:
The name of the pgq queue.

Definition at line 212 of file pgq.hpp.

Register as a consumer with pgq.

This method connects to the database and registers the pgq consumer. If it returns without an exception, the consumer is registered.

Returns:
a boolean that indicates whether the consumer was registered by this call. False indicates that the consumer had been registered already.

True if consumer was registered with this query. False if it had been registered already.

Definition at line 67 of file pgq.hpp.

Unregister the consumer.

This method connects to the database and unregisters the pgq consumer. If it returns without an exception, the consumer is not registered.

Returns:
a boolean that indicates whether the consumer was unregistered by this call. False indicates that the consumer had not been registered at all.

True if consumer was registered with this query. False if it had been registered already.

Definition at line 97 of file pgq.hpp.


Member Data Documentation

std::string const moost::psql::pgq_consumer::m_consumer_name [private]

Definition at line 229 of file pgq.hpp.

std::string const moost::psql::pgq_consumer::m_dbconn [private]

Definition at line 227 of file pgq.hpp.

std::string const moost::psql::pgq_consumer::m_queue_name [private]

Definition at line 228 of file pgq.hpp.


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