libmoost
|
This class represents a consumer for a queue in pgq. More...
#include <pgq.hpp>
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 |
moost::psql::pgq_consumer::pgq_consumer | ( | std::string const & | dbconn, |
std::string const & | queue_name, | ||
std::string const & | consumer_name | ||
) | [inline] |
dbconn | the postgres db connection specification |
queue_name | the name of the queue in pgq |
consumer_name | the name under which this pgq_consumer object shall register |
std::string const& moost::psql::pgq_consumer::consumer_name | ( | ) | const [inline] |
std::string const& moost::psql::pgq_consumer::dbconn | ( | ) | const [inline] |
bool moost::psql::pgq_consumer::is_registered | ( | ) | const [inline] |
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.
functor | The functor to be called for each pqxx::result object. |
std::string const& moost::psql::pgq_consumer::queue_name | ( | ) | const [inline] |
bool moost::psql::pgq_consumer::register_consumer | ( | ) | const [inline] |
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.
True if consumer was registered with this query. False if it had been registered already.
bool moost::psql::pgq_consumer::unregister_consumer | ( | ) | const [inline] |
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.
True if consumer was registered with this query. False if it had been registered already.
std::string const moost::psql::pgq_consumer::m_consumer_name [private] |
std::string const moost::psql::pgq_consumer::m_dbconn [private] |
std::string const moost::psql::pgq_consumer::m_queue_name [private] |