Dripline-Cpp  v2.10.11
Dripline Implementation in C++
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Friends | List of all members
core Class Reference

Basic AMQP interactions, including sending messages and interacting with AMQP channels. More...

#include <core.hh>

Inheritance diagram for core:
Inheritance graph

Public Types

enum class  post_listen_status {
  unknown , message_received , timeout , soft_error ,
  hard_error
}
 

Public Member Functions

 core (const scarab::param_node &a_config=dripline_config(), const scarab::authentication &a_auth=scarab::authentication(), const bool a_make_connection=true)
 
 core (const core &a_orig)=default
 
 core (core &&a_orig)=default
 
virtual ~core ()=default
 
coreoperator= (const core &a_orig)=default
 
coreoperator= (core &&a_orig)=default
 
virtual sent_msg_pkg_ptr send (request_ptr_t a_request, amqp_channel_ptr a_channel=amqp_channel_ptr()) const
 
virtual sent_msg_pkg_ptr send (reply_ptr_t a_reply, amqp_channel_ptr a_channel=amqp_channel_ptr()) const
 
virtual sent_msg_pkg_ptr send (alert_ptr_t a_alert, amqp_channel_ptr a_channel=amqp_channel_ptr()) const
 
 snake_case_mv_referrable (std::string, address)
 
 snake_case_mv_accessible (unsigned, port)
 
 snake_case_mv_referrable (std::string, username)
 
 snake_case_mv_referrable (std::string, password)
 
 snake_case_mv_referrable (std::string, requests_exchange)
 
 snake_case_mv_referrable (std::string, alerts_exchange)
 
 snake_case_mv_referrable (std::string, heartbeat_routing_key)
 
 snake_case_mv_accessible (unsigned, max_payload_size)
 
 snake_case_mv_accessible (bool, make_connection)
 
 snake_case_mv_accessible (unsigned, max_connection_attempts)
 

Static Public Member Functions

static void listen_for_message (amqp_envelope_ptr &a_envelope, post_listen_status &a_status, amqp_channel_ptr a_channel, const std::string &a_consumer_tag, int a_timeout_ms=0, bool a_do_ack=true)
 listen for a single AMQP message More...
 

Static Public Attributes

static bool s_offline = false
 

Protected Member Functions

sent_msg_pkg_ptr do_send (message_ptr_t a_message, const std::string &a_exchange, bool a_expect_reply, amqp_channel_ptr a_channel=amqp_channel_ptr()) const
 
amqp_channel_ptr send_withreply (message_ptr_t a_message, std::string &a_reply_consumer_tag, const std::string &a_exchange) const
 
bool send_noreply (message_ptr_t a_message, const std::string &a_exchange) const
 
amqp_channel_ptr open_channel () const
 

Static Protected Member Functions

static bool setup_exchange (amqp_channel_ptr a_channel, const std::string &a_exchange)
 
static bool setup_queue (amqp_channel_ptr a_channel, const std::string &a_queue_name)
 
static bool bind_key (amqp_channel_ptr a_channel, const std::string &a_exchange, const std::string &a_queue_name, const std::string &a_routing_key)
 
static std::string start_consuming (amqp_channel_ptr a_channel, const std::string &a_queue_name)
 
static bool stop_consuming (amqp_channel_ptr a_channel, std::string &a_consumer_tag)
 
static bool remove_queue (amqp_channel_ptr a_channel, const std::string &a_queue_name)
 

Friends

class receiver
 

Detailed Description

Basic AMQP interactions, including sending messages and interacting with AMQP channels.

Author
N.S. Oblath

The configuration for a core object is supplied via the constructor. The basic required information can be obtained from dripline_config. The configuration values have default parameters, and they can be modified with the config param_node, and a few parameters can be specified explicitly as constructor arguments. The order of precedence for those values is (items higher in the list override those below them): Constructor arguments (other than a_config) Config param_node object Defaults

If the broker is not specified in either the config object or as a constructor parameter, it will be requested from the authentication file.

A second constructor allows a user to create a core object without connecting to a broker.

The primary user interface is core::send(), one of which exists for each type of message (request, reply, and alert).

Core also contains a number of utility functions that wrap the main interactions with AMQP channels.
Classes wishing to take advantage of those functions should inherit from core.

Definition at line 74 of file core.hh.

Member Enumeration Documentation

◆ post_listen_status

enum post_listen_status
strong
Enumerator
unknown 

Initialized or unknown status.

message_received 

A message was received, and the channel is still valid.

timeout 

A timeout occurred, and the channel is still valid.

soft_error 

An error occurred, but the channel should still be valid.

hard_error 

An error occurred, and the channel is no longer valid.

Definition at line 79 of file core.hh.

Constructor & Destructor Documentation

◆ core() [1/3]

core ( const scarab::param_node &  a_config = dripline_config(),
const scarab::authentication &  a_auth = scarab::authentication(),
const bool  a_make_connection = true 
)

Definition at line 51 of file core.cc.

◆ core() [2/3]

core ( const core a_orig)
default

◆ core() [3/3]

core ( core &&  a_orig)
default

◆ ~core()

virtual ~core ( )
virtualdefault

Member Function Documentation

◆ bind_key()

bool bind_key ( amqp_channel_ptr  a_channel,
const std::string &  a_exchange,
const std::string &  a_queue_name,
const std::string &  a_routing_key 
)
staticprotected

Definition at line 411 of file core.cc.

◆ do_send()

sent_msg_pkg_ptr do_send ( message_ptr_t  a_message,
const std::string &  a_exchange,
bool  a_expect_reply,
amqp_channel_ptr  a_channel = amqp_channel_ptr() 
) const
protected

Definition at line 185 of file core.cc.

◆ listen_for_message()

void listen_for_message ( amqp_envelope_ptr a_envelope,
core::post_listen_status a_status,
amqp_channel_ptr  a_channel,
const std::string &  a_consumer_tag,
int  a_timeout_ms = 0,
bool  a_do_ack = true 
)
static

listen for a single AMQP message

Definition at line 528 of file core.cc.

◆ open_channel()

amqp_channel_ptr open_channel ( ) const
protected

Definition at line 277 of file core.cc.

◆ operator=() [1/2]

core& operator= ( const core a_orig)
default

◆ operator=() [2/2]

core& operator= ( core &&  a_orig)
default

◆ remove_queue()

bool remove_queue ( amqp_channel_ptr  a_channel,
const std::string &  a_queue_name 
)
staticprotected

Definition at line 498 of file core.cc.

◆ send() [1/3]

sent_msg_pkg_ptr send ( alert_ptr_t  a_alert,
amqp_channel_ptr  a_channel = amqp_channel_ptr() 
) const
virtual

Sends an alert message Default exchange is "alerts" Caller can supply a channel; if one is not supplied, a new channel will be established

Reimplemented in service.

Definition at line 174 of file core.cc.

◆ send() [2/3]

sent_msg_pkg_ptr send ( reply_ptr_t  a_reply,
amqp_channel_ptr  a_channel = amqp_channel_ptr() 
) const
virtual

Sends a reply message Default exchange is "requests" Caller can supply a channel; if one is not supplied, a new channel will be established

Reimplemented in service.

Definition at line 163 of file core.cc.

◆ send() [3/3]

sent_msg_pkg_ptr send ( request_ptr_t  a_request,
amqp_channel_ptr  a_channel = amqp_channel_ptr() 
) const
virtual

Sends a request message and returns a channel on which to listen for a reply. Default exchange is "requests" Caller can supply a channel; if one is not supplied, a new channel will be established

Reimplemented in service.

Definition at line 152 of file core.cc.

◆ send_noreply()

bool send_noreply ( message_ptr_t  a_message,
const std::string &  a_exchange 
) const
protected

◆ send_withreply()

amqp_channel_ptr send_withreply ( message_ptr_t  a_message,
std::string &  a_reply_consumer_tag,
const std::string &  a_exchange 
) const
protected

◆ setup_exchange()

bool setup_exchange ( amqp_channel_ptr  a_channel,
const std::string &  a_exchange 
)
staticprotected

Definition at line 360 of file core.cc.

◆ setup_queue()

bool setup_queue ( amqp_channel_ptr  a_channel,
const std::string &  a_queue_name 
)
staticprotected

Definition at line 385 of file core.cc.

◆ snake_case_mv_accessible() [1/4]

snake_case_mv_accessible ( bool  ,
make_connection   
)

◆ snake_case_mv_accessible() [2/4]

snake_case_mv_accessible ( unsigned  ,
max_connection_attempts   
)

◆ snake_case_mv_accessible() [3/4]

snake_case_mv_accessible ( unsigned  ,
max_payload_size   
)

◆ snake_case_mv_accessible() [4/4]

snake_case_mv_accessible ( unsigned  ,
port   
)

◆ snake_case_mv_referrable() [1/6]

snake_case_mv_referrable ( std::string  ,
address   
)

◆ snake_case_mv_referrable() [2/6]

snake_case_mv_referrable ( std::string  ,
alerts_exchange   
)

◆ snake_case_mv_referrable() [3/6]

snake_case_mv_referrable ( std::string  ,
heartbeat_routing_key   
)

◆ snake_case_mv_referrable() [4/6]

snake_case_mv_referrable ( std::string  ,
password   
)

◆ snake_case_mv_referrable() [5/6]

snake_case_mv_referrable ( std::string  ,
requests_exchange   
)

◆ snake_case_mv_referrable() [6/6]

snake_case_mv_referrable ( std::string  ,
username   
)

◆ start_consuming()

std::string start_consuming ( amqp_channel_ptr  a_channel,
const std::string &  a_queue_name 
)
staticprotected

Definition at line 437 of file core.cc.

◆ stop_consuming()

bool stop_consuming ( amqp_channel_ptr  a_channel,
std::string &  a_consumer_tag 
)
staticprotected

Definition at line 462 of file core.cc.

Friends And Related Function Documentation

◆ receiver

friend class receiver
friend

Definition at line 145 of file core.hh.

Member Data Documentation

◆ s_offline

bool s_offline = false
static

Definition at line 77 of file core.hh.


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