bneradt commented on a change in pull request #8204:
URL: https://github.com/apache/trafficserver/pull/8204#discussion_r684369017



##########
File path: example/plugins/cpp-api/transaction_data_sink/TransactionDataSink.cc
##########
@@ -28,89 +28,91 @@
   limitations under the License.
  */
 
-#include <stdio.h>
-#include <unistd.h>
 #include <ts/ts.h>
 
-// This gets the PRI*64 types
-#define __STDC_FORMAT_MACROS 1
-#include <inttypes.h>
+#include <string>
+#include <string_view>
 
-#define PLUGIN_NAME "txn_data_sink"
-#define PCP "[" PLUGIN_NAME "] "
+namespace
+{
+std::string const PLUGIN_NAME = "txn_data_sink";
 
-// Activate the data sink if this field is present in the request.
-static const char FLAG_MIME_FIELD[] = "TS-Agent";
-static size_t const FLAG_MIME_LEN   = sizeof(FLAG_MIME_FIELD) - 1;
+/** Activate the data sink if this header field is present in the request. */
+std::string const FLAG_HEADER_FIELD = "TS-Agent";
 
-typedef struct {
-  int64_t total;
-} SinkData;
+/** The sink data for a transaction. */
+struct SinkData {
+  /** The bytes for the response body streamed in from the sink. */
+  std::string body_bytes;
+};
 
 // This serves to consume all the data that arrives. If it's not consumed the 
tunnel gets stalled
 // and the transaction doesn't complete. Other things could be done with the 
data, accessible via
 // the IO buffer @a reader, such as writing it to disk to make an externally 
accessible copy.
-static int
+int
 client_reader(TSCont contp, TSEvent event, void *edata)
 {
-  SinkData *data = TSContDataGet(contp);
+  SinkData *data = reinterpret_cast<SinkData *>(TSContDataGet(contp));

Review comment:
       Yep, that works.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to