Dripline-Cpp  v2.4.2
Dripline Implementation in C++
core.hh
Go to the documentation of this file.
1 /*
2  * core.hh
3  *
4  * Created on: Jul 13, 2015
5  * Author: N.S. Oblath
6  */
7 
8 #ifndef DRIPLINE_CORE_HH_
9 #define DRIPLINE_CORE_HH_
10 
11 #include "message.hh"
12 
13 #include <map>
14 #include <mutex>
15 #include <thread>
16 
17 namespace scarab
18 {
19  class param_node;
20 }
21 
22 namespace dripline
23 {
38  {
39  std::mutex f_mutex;
41  std::string f_consumer_tag;
43  std::string f_send_error_message;
44  ~sent_msg_pkg();
45  };
46 
73  {
74  public:
75  static bool s_offline;
76 
77  public:
81  core( const scarab::param_node& a_config = scarab::param_node(), const std::string& a_broker_address = "", unsigned a_port = 0, const std::string& a_auth_file = "", const bool a_make_connection = true );
82  core( const bool a_make_connection, const scarab::param_node& a_config = scarab::param_node() );
83  core( const core& a_orig );
84  core( core&& a_orig );
85  //core( const scarab::param_node* a_config = nullptr );
86  virtual ~core();
87 
88  core& operator=( const core& a_orig );
89  core& operator=( core&& a_orig );
90 
91  public:
94  virtual sent_msg_pkg_ptr send( request_ptr_t a_request ) const;
95 
98  virtual sent_msg_pkg_ptr send( reply_ptr_t a_reply ) const;
99 
102  virtual sent_msg_pkg_ptr send( alert_ptr_t a_alert ) const;
103 
104  mv_referrable( std::string, address );
105  mv_accessible( unsigned, port );
106  mv_referrable( std::string, username );
107  mv_referrable( std::string, password );
108 
109  mv_referrable( std::string, requests_exchange );
110  mv_referrable( std::string, alerts_exchange );
111 
112  mv_referrable( std::string, heartbeat_routing_key );
113 
114  mv_accessible( unsigned, max_payload_size );
115 
116  mv_accessible( bool, make_connection );
117 
118  protected:
119  friend class receiver;
120 
121  sent_msg_pkg_ptr do_send( message_ptr_t a_message, const std::string& a_exchange, bool a_expect_reply ) const;
122 
123  amqp_channel_ptr send_withreply( message_ptr_t a_message, std::string& a_reply_consumer_tag, const std::string& a_exchange ) const;
124 
125  bool send_noreply( message_ptr_t a_message, const std::string& a_exchange ) const;
126 
127  amqp_channel_ptr open_channel() const;
128 
129  static bool setup_exchange( amqp_channel_ptr a_channel, const std::string& a_exchange );
130 
131  static bool setup_queue( amqp_channel_ptr a_channel, const std::string& a_queue_name );
132 
133  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 );
134 
135  static std::string start_consuming( amqp_channel_ptr a_channel, const std::string& a_queue_name );
136 
137  static bool stop_consuming( amqp_channel_ptr a_channel, std::string& a_consumer_tag );
138 
139  static bool remove_queue( amqp_channel_ptr a_channel, const std::string& a_queue_name );
140 
141  public:
143  static bool listen_for_message( amqp_envelope_ptr& a_envelope, amqp_channel_ptr a_channel, const std::string& a_consumer_tag, int a_timeout_ms = 0, bool a_do_ack = true );
144  };
145 
146 } /* namespace dripline */
147 
148 #endif /* DRIPLINE_CORE_HH_ */
std::mutex f_mutex
Definition: core.hh:39
std::shared_ptr< sent_msg_pkg > sent_msg_pkg_ptr
Definition: dripline_fwd.hh:27
std::shared_ptr< msg_request > request_ptr_t
Definition: dripline_fwd.hh:23
std::shared_ptr< msg_alert > alert_ptr_t
Definition: dripline_fwd.hh:25
Definition: core.hh:17
amqp_channel_ptr f_channel
Definition: core.hh:40
#define DRIPLINE_API
Definition: dripline_api.hh:34
A receiver is able to collect Dripline message chunks and reassemble them into a complete Dripline me...
Definition: receiver.hh:76
std::string f_consumer_tag
Definition: core.hh:41
std::string f_send_error_message
Definition: core.hh:43
AmqpClient::Channel::ptr_t amqp_channel_ptr
Definition: amqp.hh:24
std::shared_ptr< msg_reply > reply_ptr_t
Definition: dripline_fwd.hh:24
Contains information about sent messages.
Definition: core.hh:37
AmqpClient::Envelope::ptr_t amqp_envelope_ptr
Definition: amqp.hh:25
Basic AMQP interactions, including sending messages and interacting with AMQP channels.
Definition: core.hh:72
static bool s_offline
Definition: core.hh:75
std::shared_ptr< message > message_ptr_t
Definition: dripline_fwd.hh:20
bool f_successful_send
Definition: core.hh:42