Apama  10.15.5.0
sag_connectivity_plugins.hpp
Go to the documentation of this file.
1 /*
2  * Title: sag_connectivity_plugins.hpp
3  * Description: C++ API for writing connectivity plugins
4  * $Copyright (c) 2015-2024 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.$
5  * Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG
6  */
7 
16 #ifndef _SAG_CONNECTIVITY_PLUGINS_HPP_
17 #define _SAG_CONNECTIVITY_PLUGINS_HPP_
18 
19 #include <sag_connectivity_cpp.hpp>
20 #include <sag_plugin_logging.hpp>
21 #include <memory>
22 #include <mutex>
23 
24 // must define __STDC_FORMAT_MACROS before first include of inttypes else printf macros won't be defined
25 #ifndef __STDC_FORMAT_MACROS
26 #define __STDC_FORMAT_MACROS 1
27 #endif
28 #include <inttypes.h>
29 
30 namespace com {
31 namespace softwareag {
32 namespace _DATAT_INTERNAL_CPP_NAMESPACE {
33 
34 namespace
35 {
39  void replace(std::string &input, const std::string &from, const std::string &to)
40  {
41  size_t pos = 0;
42  while((pos = input.find(from, pos)) != std::string::npos)
43  {
44  input.replace(pos, from.length(), to);
45  pos += to.length();
46  }
47  }
48 
52  std::string to_string(const Message &m, bool truncate=true)
53  {
54  std::string payload = to_string(m.getPayload());
55  if (truncate && payload.length() > 200) payload = payload.substr(0, 196) + " ...";
56  // security sanitization to prevent log message faking
57  replace(payload, "\n", "\\n");
58  replace(payload, "\r", "\\r");
59  return "Message<metadata="+to_string(m.getMetadataMap())+", payload="+payload+">";
60  }
61 }
62 
68 enum class Direction {
72  TOWARDS_HOST = 1,
77 
78 };
79 
84 class PluginHost {
85  friend class Plugin;
86 public:
87  typedef std::unique_ptr<PluginHost> ptr_t;
88 
103  void enableReliability(Direction direction) {
104  if (SAG_ERROR_OK != sag_enable_reliability(chain, static_cast<int>(direction))) {
105  throw std::runtime_error("An error occurred while setting chain reliability");
106  }
107  }
108 
123  if (SAG_ERROR_OK != sag_enable_queue_flush_messages(chain)) {
124  throw std::runtime_error("An error occurred while enabling queue flush messages");
125  }
126  }
127 
129  bool isShuttingDown() {
130  bool isShuttingDown = false;
131  if (SAG_ERROR_OK != sag_is_host_shutting_down(chain, isShuttingDown)) {
132  throw std::runtime_error("An error occurred while checking if host is shutting down");
133  }
134  return isShuttingDown;
135  }
136 private:
140  PluginHost(void* chain = nullptr) :chain(chain) {}
141  void* chain;
142 };
143 
144 // forward decl for parameters friend
145 class Plugin;
146 
157 {
158  // for constructor access to connectivityManager
159  friend class Plugin;
160 
161 public:
163 
165 
170  const map_t &getConfig() const { return config; }
171 
175  const std::string &getChainId() const { return chainId; }
176 
180  const std::string &getPluginName() const { return pluginName; }
181 
182 protected:
186  PluginConstructorParameters(const std::string &pluginName, const std::string &chainId, const map_t &config, void* connectivityManager, void* chain)
187  : chainId(chainId), pluginName(pluginName), config(config.copy()), connectivityManager(connectivityManager), chain(chain)
188  {}
189 
190 private:
191  std::string chainId;
192  std::string pluginName;
193  map_t config;
195  void* connectivityManager;
197  void* chain;
198 };
199 
202 {
203 public:
207  TransportConstructorParameters(const std::string &pluginName, const std::string &chainId, const map_t &config, void* connectivityManager, void* reserved)
208  : PluginConstructorParameters(pluginName, chainId, config, connectivityManager, reserved)
209  {}
210 };
211 
214 {
215 public:
219  CodecConstructorParameters(const std::string &pluginName, const std::string &chainId, const map_t &config, void* connectivityManager, void* reserved)
220  : PluginConstructorParameters(pluginName, chainId, config, connectivityManager, reserved)
221  {}
225  CodecConstructorParameters(const std::string &pluginName)
226  : PluginConstructorParameters(pluginName, "", map_t{}, nullptr, nullptr)
227  {}
228 };
229 
230 
241 {
242 public:
243 
247  static const char* STATUS_ONLINE() { return "ONLINE"; }
251  static const char* STATUS_STARTING() { return "STARTING"; }
255  static const char* STATUS_FAILED() { return "FAILED"; }
256 
267  {
268  friend class StatusReporter;
269  public:
270 
271  ~StatusItem()
272  {
273  sag_delete_user_status_item(connectivityManager, underlying);
274  underlying.item = nullptr;
275  }
276 
284  void setStatus(const std::string &value)
285  {
286  std::unique_lock<std::mutex> ul(status_lock);
287  setStatusLocked(value);
288  }
289 
298  void setStatus(int64_t value)
299  {
300  std::unique_lock<std::mutex> ul(status_lock);
301  intValue = value;
302  setStatusLocked(convert_to_details::integerToString(value));
303  }
304 
312  std::string getStatus() {
313  std::unique_lock<std::mutex> ul(status_lock);
314  return lastValue;
315  }
316 
324  void increment(int64_t incrementValue = 1)
325  {
326  if (incrementValue == 0) return;
327  std::unique_lock<std::mutex> ul(status_lock);
328  intValue += incrementValue;
329  setStatusLocked(convert_to_details::integerToString(intValue));
330  }
331 
334  const std::string &key() { return mkey; }
335 
336  private:
337  StatusItem(const StatusItem& other) = delete; // non construction-copyable
338  StatusItem& operator=(const StatusItem&) = delete; // non copyable
339 
340  StatusItem(void* connectivityManager, const std::string &key, const std::string &initialValue, const int64_t intValue)
341  : intValue(intValue),
342  mkey(key),
343  lastValue(initialValue),
344  connectivityManager(connectivityManager),
345  underlying(sag_create_user_status_item(connectivityManager, key.c_str(), initialValue.c_str()))
346  {
347  if (!underlying.item)
348  {
349  std::ostringstream oss;
350  oss << "Failed to create status item '" << key << "' (ensure the key is unique and that this plug-in has not been shutdown already)";
351  throw std::runtime_error(oss.str());
352  }
353  }
354 
355  void setStatusLocked(const std::string &value)
356  {
357  if (value == lastValue) return; // no-op this case
358  lastValue = value;
359 
360  sag_set_user_status_item(underlying, value.c_str());
361  }
362 
363  int64_t intValue;
364  const std::string mkey;
365  std::string lastValue;
366  void* connectivityManager;
367  sag_status_item_t underlying;
368  std::mutex status_lock;
369  };
370 
372  typedef std::unique_ptr<StatusItem> item_ptr;
373 
388  item_ptr createStatusItem(const std::string &key, const std::string &initialValue)
389  {
390  return std::unique_ptr<StatusItem>(new StatusItem(connectivityManager, key, initialValue, 0));
391  }
392 
406  item_ptr createStatusItem(const std::string &key, int64_t initialValue)
407  {
408  std::ostringstream oss;
409  oss << initialValue;
410  return std::unique_ptr<StatusItem>(new StatusItem(connectivityManager, key, oss.str(), initialValue));
411  }
412 
424  void setStatus(const map_t &statusmap)
425  {
426  sag_set_user_status_map(connectivityManager, reinterpret_cast<const sag_underlying_map_t&>(statusmap));
427  // keep track of what keys we've added so we can automatically remove them when we're destroyed
428  for (auto it = statusmap.cbegin(); it != statusmap.cend(); it++)
429  if (it->first.type_tag() == SAG_DATA_STRING) // ignore invalid ones
430  {
431  if (it->second.empty())
432  mapKeysToCleanup.erase(it->first);
433  else
434  mapKeysToCleanup.insert(it->first.copy(), data_t());
435  }
436  }
437 
438 
439 
443  ~StatusReporter()
444  {
445  if (!mapKeysToCleanup.empty())
446  sag_set_user_status_map(connectivityManager, reinterpret_cast<const sag_underlying_map_t&>(mapKeysToCleanup));
447  }
448 
452  explicit StatusReporter(void *connectivityManager) : connectivityManager(connectivityManager), mapKeysToCleanup()
453  {
454  }
455 
456 private:
457  void* connectivityManager;
458  map_t mapKeysToCleanup;
459 
460 
461  StatusReporter() = delete;
462 
463  // non-copyable, due to the cleanup code we don't want people to shoot themselves in the foot by having multiple copies
464  StatusReporter(const StatusReporter& other) = delete;
465  StatusReporter& operator=(const StatusReporter&) = delete;
466 
467 };
468 
476 class Plugin
477 {
478 public:
479  /* Constructor.
480  * @since 9.12.0.1
481  */
482  Plugin(const PluginConstructorParameters &params)
483  : pluginName(params.getPluginName()), chainId(params.getChainId()), config(params.getConfig().copy()),
484  host(new PluginHost(params.chain)), logger("connectivity." + pluginName + "." + chainId),
485  statusReporter(new StatusReporter(params.connectivityManager))
486  {
487  }
488 
494  virtual ~Plugin() {}
495 
506  virtual void start() {}
507 
515  virtual void hostReady() {}
516 
541  virtual void shutdown() {}
543  const std::string &getName() const { return pluginName; }
544 protected:
548  const std::string pluginName;
550  const std::string chainId;
558  const PluginHost::ptr_t host;
567  if (statusReporter) return *statusReporter;
568  throw std::runtime_error("Cannot call getStatusReporter when using the legacy constructor");
569  }
570 
571 public:
576 private:
577  std::unique_ptr<StatusReporter> statusReporter;
578 };
579 
584 class HostSide
585 {
586 public:
588  virtual ~HostSide() {}
590  typedef std::unique_ptr<HostSide> ptr_t;
610  virtual void sendBatchTowardsHost(Message *start, Message *end) = 0;
611 
619  void sendBatchTowardsHost(Message &&message) {
620  sendBatchTowardsHost(&message, &message+1);
621  }
622 
633  template<typename IT>
634  auto sendBatchTowardsHost(const IT &begin, const IT &end) -> typename std::enable_if<
635  !std::is_const<ampl::remove_ref_t<decltype(*begin)>>::value &&
636  ampl::is_same<Message, ampl::remove_const_t<ampl::remove_ref_t<decltype(*begin)>>>::value
637  , void>::type // this ensures we can only pass in non-const iterator pairs to Message
638  {
639  if(begin == end) sendBatchTowardsHost((Message*) nullptr, (Message*) nullptr);
640  else sendBatchTowardsHost(&(*begin), (&(*(end-1)))+1);
641  }
642 };
643 
648 class RemoteHostSide: public HostSide
649 {
650 public:
651  RemoteHostSide(sag_plugin_t other, sag_send_fn_t fn): other(other), fn(fn) {}
652  virtual ~RemoteHostSide() {}
653  virtual void sendBatchTowardsHost(Message *start, Message *end);
654 private:
655  sag_plugin_t other;
656  sag_send_fn_t fn;
657 };
658 
664 {
665 public:
667  virtual ~TransportSide() {}
669  typedef std::unique_ptr<TransportSide> ptr_t;
690  virtual void sendBatchTowardsTransport(Message *start, Message *end) = 0;
691 
700  sendBatchTowardsTransport(&message, &message+1);
701  }
702 
712  template<typename IT>
713  auto sendBatchTowardsTransport(const IT &begin, const IT &end) -> typename std::enable_if<
714  !std::is_const<ampl::remove_ref_t<decltype(*begin)>>::value &&
715  ampl::is_same<Message, ampl::remove_const_t<ampl::remove_ref_t<decltype(*begin)>>>::value
716  , void>::type // this ensures we can only pass in non-const iterator pairs to Message
717  {
718  if(begin == end) sendBatchTowardsTransport((Message*) nullptr, (Message*) nullptr);
719  else sendBatchTowardsTransport(&(*begin), (&(*(end-1)))+1);
720  }
721 };
722 
727 class RemoteTransportSide: public TransportSide
728 {
729 public:
730  RemoteTransportSide(sag_plugin_t other, sag_send_fn_t fn): other(other), fn(fn) {}
731  virtual ~RemoteTransportSide() {}
732  virtual void sendBatchTowardsTransport(Message *start, Message *end);
733 private:
734  sag_plugin_t other;
735  sag_send_fn_t fn;
736 };
737 
738 
760 class AbstractCodec: public Plugin, public HostSide, public TransportSide
761 {
762 public:
764 
774  : Plugin(params)
775  {}
776 
777  // These methods do not need to show up in doxygen
778  /* Called between construction and start() to set the hostSide field */
779  virtual void setNextTowardsHost(HostSide::ptr_t &&host)
780  {
781  hostSide = std::move(host);
782  }
783  /* Called between construction and start() to set the transportSide field */
784  virtual void setNextTowardsTransport(TransportSide::ptr_t &&transport)
785  {
786  transportSide = std::move(transport);
787  }
788 protected:
794 
800 };
801 
831 {
832 public:
834 
844  : Plugin(params)
845  {}
846 
847  // This method does not need to show up in doxygen
848  /* Called between construction and start() to set the hostSide field */
849  virtual void setNextTowardsHost(HostSide::ptr_t &&host)
850  {
851  hostSide = std::move(host);
852  }
853 
854 protected:
860 };
861 
874 {
875 public:
876 
886  : AbstractTransport(params)
887  {}
888 
889 
895  virtual void sendBatchTowardsTransport(Message *start, Message *end)
896  {
897  for (Message *it = start; it != end; ++it) {
898  try {
899  if (it->getPayload().empty()) {
900  deliverNullPayloadTowardsTransport(*it);
901  } else {
902  deliverMessageTowardsTransport(*it);
903  }
904  } catch (...) {
905  handleException(*it);
906  }
907  }
908  }
910  virtual void deliverMessageTowardsTransport(Message &msg) = 0;
913  {
914  // do nothing
915  }
916 
935  virtual void handleException(Message &m)
936  {
937  try {
938  throw;
939  } catch (const std::exception &e) {
940  logger.warn("Error while delivering message: %s; %s will be dropped.", e.what(), to_string(m).c_str());
941  } catch (...) {
942  logger.warn("Unknown error delivering message: %s", to_string(m).c_str());
943  }
944  }
945 };
946 
963 {
964 public:
965 
975  : AbstractCodec(params)
976  {}
977 
984  virtual void sendBatchTowardsHost(Message *start, Message *end)
985  {
986  Message *curr = start;
987  for (Message *it = start; it != end; ++it) {
988  bool rv;
989  try {
990  if (it->getPayload().empty()) {
991  rv = transformNullPayloadTowardsHost(*it);
992  } else {
993  rv = transformMessageTowardsHost(*it);
994  }
995  } catch (...) {
996  rv = handleException(*it, false);
997  }
998  // if we keep it (and it didn't throw) swap it with the accumulator
999  if (rv) {
1000  if (it != curr) it->swap(std::move(*curr)); // don't self-swap
1001  ++curr;
1002  }
1003  }
1004  if (hostSide.get()) hostSide->sendBatchTowardsHost(start, curr);
1005  }
1012  virtual void sendBatchTowardsTransport(Message *start, Message *end)
1013  {
1014  Message *curr = start;
1015  for (Message *it = start; it != end; ++it) {
1016  bool rv;
1017  try {
1018  // process the message
1019  if (it->getPayload().empty()) {
1020  rv = transformNullPayloadTowardsTransport(*it);
1021  } else {
1022  rv = transformMessageTowardsTransport(*it);
1023  }
1024  } catch (...) {
1025  rv = handleException(*it, true);
1026  }
1027  // if we keep it (and it didn't throw) swap it with the accumulator
1028  if (rv) {
1029  if (it != curr) it->swap(std::move(*curr)); // don't self-swap
1030  ++curr;
1031  }
1032  }
1033  if (transportSide.get()) transportSide->sendBatchTowardsTransport(start, curr);
1034  }
1035 
1040  virtual bool transformMessageTowardsHost(Message &msg) = 0;
1045  virtual bool transformMessageTowardsTransport(Message &msg) = 0;
1051  {
1052  // do nothing
1053  return true;
1054  }
1060  {
1061  // do nothing
1062  return true;
1063  }
1085  virtual bool handleException(Message &m, bool towardsTransport)
1086  {
1087  try {
1088  throw;
1089  } catch (const std::exception &e) {
1090  logger.warn("Error while transforming message: %s; %s will be dropped.", e.what(), to_string(m).c_str());
1091  } catch (...) {
1092  logger.warn("Unknown error transforming message: %s", to_string(m).c_str());
1093  }
1094  return false;
1095  }
1096 };
1097 
1098 }
1099 
1100 namespace connectivity { using namespace _DATAT_INTERNAL_CPP_NAMESPACE; }
1101 
1102 }} // com.softwareag.connectivity
1103 
1104 // internal implementation included from these files
1105 #include <sag_internal/exception.hpp>
1106 #include <sag_internal/remote_plugins.hpp>
1107 #include <sag_internal/plugin_macros.hpp>
1108 
1118 #define SAG_DECLARE_CONNECTIVITY_TRANSPORT_CLASS(Class) _SAG_DECLARE_CONNECTIVITY_TRANSPORT_CLASS(Class)
1119 
1129 #define SAG_DECLARE_CONNECTIVITY_CODEC_CLASS(Class) _SAG_DECLARE_CONNECTIVITY_CODEC_CLASS(Class)
1130 
1131 #endif // _SAG_CONNECTIVITY_PLUGINS_HPP_
A container for parameters passed to the constructor of a codec plug-in.
Definition: sag_connectivity_plugins.hpp:213
const std::string pluginName
The name used for this plug-in in the configuration file.
Definition: sag_connectivity_plugins.hpp:548
Base class that simplifies implementation of codec plug-ins that deal only with individual messages n...
Definition: sag_connectivity_plugins.hpp:962
AbstractTransport(const PluginConstructorParameters::TransportConstructorParameters &params)
Constructor.
Definition: sag_connectivity_plugins.hpp:843
Base class that simplifies implementation of transport plug-ins that deal only with individual messag...
Definition: sag_connectivity_plugins.hpp:873
void increment(int64_t incrementValue=1)
Set an integer status value by incrementing the previous integer value that was set by this object.
Definition: sag_connectivity_plugins.hpp:324
HostSide::ptr_t hostSide
The next plug-in in the chain towards host.
Definition: sag_connectivity_plugins.hpp:793
An interface to the next component (plugin or host) towards the host.
Definition: sag_connectivity_plugins.hpp:584
const_iterator cbegin() const
Forward const_iterator begin.
Definition: sag_connectivity_cpp.hpp:313
map_t config
The configuration of this plug-in.
Definition: sag_connectivity_plugins.hpp:552
item_ptr createStatusItem(const std::string &key, int64_t initialValue)
Creates a StatusItem instance that can be used to report status for a given key, using an integral in...
Definition: sag_connectivity_plugins.hpp:406
Direction
The enumeration indicating the direction of message flow - towards the transport or towards the host.
Definition: sag_connectivity_plugins.hpp:68
Class for writing to the system logger.
Definition: sag_plugin_logging.hpp:71
const PluginHost::ptr_t host
Interface to support miscellaneous requests from this plug-in to the host system.
Definition: sag_connectivity_plugins.hpp:558
StatusReporter & getStatusReporter()
Allows reporting status information from this plug-in, such as online or failed status and number of ...
Definition: sag_connectivity_plugins.hpp:566
const_iterator cend() const
Forward const_iterator end.
Definition: sag_connectivity_cpp.hpp:315
Contains the C++ implementation of the underlying datatypes used by connectivity plugins and their ac...
void setStatus(const map_t &statusmap)
Set multiple related string status values at the same time (atomically).
Definition: sag_connectivity_plugins.hpp:424
virtual void sendBatchTowardsTransport(Message *start, Message *end)
Implements batch sending, calling deliverMessageTowardsTransport(Message&) for each message individua...
Definition: sag_connectivity_plugins.hpp:895
Base of the inheritance tree for Connectivity plugins.
Definition: sag_connectivity_plugins.hpp:476
TransportSide::ptr_t transportSide
The next plug-in in the chain towards transport.
Definition: sag_connectivity_plugins.hpp:799
std::unique_ptr< StatusItem > item_ptr
Unique pointer to a StatusItem.
Definition: sag_connectivity_plugins.hpp:372
void setStatus(const std::string &value)
Set a string status value.
Definition: sag_connectivity_plugins.hpp:284
AbstractSimpleTransport(const PluginConstructorParameters::TransportConstructorParameters &params)
Constructor.
Definition: sag_connectivity_plugins.hpp:885
Logger logger
Logging for writing to the host log file.
Definition: sag_connectivity_plugins.hpp:575
virtual bool transformNullPayloadTowardsTransport(Message &msg)
Transform a message with a null payload in a transport-wards direction.
Definition: sag_connectivity_plugins.hpp:1059
virtual void start()
Called when an entire chain has been created and the plugin is allowed to start up (after all plugins...
Definition: sag_connectivity_plugins.hpp:506
auto sendBatchTowardsTransport(const IT &begin, const IT &end) -> typename std::enable_if< !std::is_const< ampl::remove_ref_t< decltype(*begin)>>::value &&ampl::is_same< Message, ampl::remove_const_t< ampl::remove_ref_t< decltype(*begin)>>>::value, void >::type
Overload for sending messages using an iterator range.
Definition: sag_connectivity_plugins.hpp:713
std::enable_if< get_underlying< T >::value, std::string >::type to_string(const T &t)
Get a string representation of t.
A class allowing a plug-in to report status values to the host.
Definition: sag_connectivity_plugins.hpp:240
std::unique_ptr< TransportSide > ptr_t
Pointers to TransportSides should always be this ptr_t type, which is a std::unique_ptr.
Definition: sag_connectivity_plugins.hpp:669
virtual ~TransportSide()
Ensure virtual destruction.
Definition: sag_connectivity_plugins.hpp:667
Base class for transport plug-ins.
Definition: sag_connectivity_plugins.hpp:830
static const char * STATUS_ONLINE()
Returns a constant that should be used as the status value when a component is online,...
Definition: sag_connectivity_plugins.hpp:247
item_ptr createStatusItem(const std::string &key, const std::string &initialValue)
Creates a StatusItem instance that can be used to report status for a given key.
Definition: sag_connectivity_plugins.hpp:388
const std::string & getName() const
The name used for this plug-in in the configuration file.
Definition: sag_connectivity_plugins.hpp:543
bool isShuttingDown()
Check if host is shutting down.
Definition: sag_connectivity_plugins.hpp:129
virtual void handleException(Message &m)
Handle an exception thrown while delivering a message towards the transport.
Definition: sag_connectivity_plugins.hpp:935
void enableQueueFlushMessages()
Enable notifications about queue flushes.
Definition: sag_connectivity_plugins.hpp:122
static const char * STATUS_FAILED()
Returns a constant that should be used as the status value when a component is not currently operatio...
Definition: sag_connectivity_plugins.hpp:255
virtual ~HostSide()
Ensure virtual destruction.
Definition: sag_connectivity_plugins.hpp:588
AbstractSimpleCodec(const PluginConstructorParameters::CodecConstructorParameters &params)
Constructor.
Definition: sag_connectivity_plugins.hpp:974
virtual void hostReady()
Called some time after start(), when the host is ready to start receiving input (sends will be queued...
Definition: sag_connectivity_plugins.hpp:515
Base class for codec plug-ins.
Definition: sag_connectivity_plugins.hpp:760
void sendBatchTowardsHost(Message &&message)
Overload for sending a batch containing a single message.
Definition: sag_connectivity_plugins.hpp:619
const std::string & getPluginName() const
Get the name used in the configuration file for this plug-in.
Definition: sag_connectivity_plugins.hpp:180
static const char * STATUS_STARTING()
Returns a constant that should be used as the status value when a component is still starting,...
Definition: sag_connectivity_plugins.hpp:251
void setStatus(int64_t value)
Set an integer status value.
Definition: sag_connectivity_plugins.hpp:298
A map class which implements many of the functions on std::map.
Definition: sag_connectivity_cpp.hpp:35
const std::string & key()
Get the unique key specified when this status item was created.
Definition: sag_connectivity_plugins.hpp:334
A class that can be used to efficiently update the value associated with a single status key.
Definition: sag_connectivity_plugins.hpp:266
A container for an payload and associated metadata.
Definition: sag_connectivity_cpp.hpp:26
virtual void shutdown()
Stop processing messages and terminate and join any background threads.
Definition: sag_connectivity_plugins.hpp:541
virtual void sendBatchTowardsHost(Message *start, Message *end)
Implements batch sending, calling transformMessageTowardsHost(Message &) for each message individuall...
Definition: sag_connectivity_plugins.hpp:984
An interface to the next component (plugin or host) towards the transport.
Definition: sag_connectivity_plugins.hpp:663
AbstractCodec(const PluginConstructorParameters::CodecConstructorParameters &params)
Constructor.
Definition: sag_connectivity_plugins.hpp:773
auto sendBatchTowardsHost(const IT &begin, const IT &end) -> typename std::enable_if< !std::is_const< ampl::remove_ref_t< decltype(*begin)>>::value &&ampl::is_same< Message, ampl::remove_const_t< ampl::remove_ref_t< decltype(*begin)>>>::value, void >::type
Overload for sending messages using an iterator range.
Definition: sag_connectivity_plugins.hpp:634
map_t copy() const
Return a deep copy of this map.
Definition: sag_connectivity_cpp.hpp:242
virtual void deliverNullPayloadTowardsTransport(Message &msg)
Deliver a message with a null payload.
Definition: sag_connectivity_plugins.hpp:912
void enableReliability(Direction direction)
Enable reliable messaging for the chain that this plug-in belongs to, in a particular direction i....
Definition: sag_connectivity_plugins.hpp:103
Contains the headers needed to implement your own Connectivity Plugins.
const std::string & getChainId() const
Get the identifier used for the chain this plug-in is part of.
Definition: sag_connectivity_plugins.hpp:175
A container for parameters passed to the constructor of a transport plug-in.
Definition: sag_connectivity_plugins.hpp:201
The direction of messages flowing towards the host (from the transport).
Interface to support miscellaneous requests from a particular plug-in to the host system.
Definition: sag_connectivity_plugins.hpp:84
A base interface for parameters passed to the constructor of transport or codec plug-ins.
Definition: sag_connectivity_plugins.hpp:156
virtual bool handleException(Message &m, bool towardsTransport)
Handle an exception thrown while delivering a message.
Definition: sag_connectivity_plugins.hpp:1085
utf8-encoded const char*
Definition: sag_connectivity_c.h:45
const std::string chainId
The identifier used for the chain this plug-in is part of.
Definition: sag_connectivity_plugins.hpp:550
The direction of messages flowing towards the transport (from the host).
void sendBatchTowardsTransport(Message &&message)
Overload for sending a batch containing a single message.
Definition: sag_connectivity_plugins.hpp:699
std::string getStatus()
Return the value this status item was set to most recently by this class.
Definition: sag_connectivity_plugins.hpp:312
A variant type which can be one of the following:
Definition: sag_connectivity_cpp.hpp:41
std::unique_ptr< HostSide > ptr_t
Pointers to HostSides should always be this ptr_t type, which is a std::unique_ptr.
Definition: sag_connectivity_plugins.hpp:590
virtual void sendBatchTowardsTransport(Message *start, Message *end)
Implements batch sending, calling transformMessageTowardsTransport(Message &) for each message indivi...
Definition: sag_connectivity_plugins.hpp:1012
const map_t & getConfig() const
Get the configuration for this plug-in.
Definition: sag_connectivity_plugins.hpp:170
virtual ~Plugin()
This destructor must be virtual.
Definition: sag_connectivity_plugins.hpp:494
HostSide::ptr_t hostSide
The next plug-in in the chain towards host.
Definition: sag_connectivity_plugins.hpp:859
virtual bool transformNullPayloadTowardsHost(Message &msg)
Transform a message with a null payload in a host-wards direction.
Definition: sag_connectivity_plugins.hpp:1050