You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2019/04/16 14:26:34 UTC

[GitHub] [nifi-minifi-cpp] arpadboda commented on a change in pull request #536: MINIFICPP-694 - Ensure that processor consist of proper phases

arpadboda commented on a change in pull request #536: MINIFICPP-694 - Ensure that processor consist of proper phases
URL: https://github.com/apache/nifi-minifi-cpp/pull/536#discussion_r275826158
 
 

 ##########
 File path: nanofi/include/api/nanofi.h
 ##########
 @@ -379,13 +379,31 @@ int8_t remove_attribute(flow_file_record*, const char * key);
 
 int transmit_flowfile(flow_file_record *, nifi_instance *);
 
+
+/****
+ * ##################################################################
+ *  API functions for user-defined processor
+ * ##################################################################
+ */
+
+typedef struct {
+  const char * name;
+  ontrigger_callback * ontr_cb;
+  onschedule_callback * onsc_cb;
+} custom_processor_args;
+
+
 /**
  * Adds a custom processor for later instantiation
  * @param name name of the processor
- * @param logic the callback to be invoked when the processor is triggered
+ * @param in the name and the callbacks used for the processor
+ * @attention it's recommended to use this function via the variadic arg macro: the caller doesn't need to create the
+ * parameter struct and callback argument can be optional.
  * @return 0 on success, -1 otherwise (name already in use for eg.)
  **/
-int add_custom_processor(const char * name, processor_logic* logic);
+int var_add_custom_processor(custom_processor_args in);
+
+#define add_custom_processor(...) var_add_custom_processor((custom_processor_args){__VA_ARGS__});
 
 Review comment:
   I know it looks weird, although this way I could extend the C API with an optional argument, so this change doesn't break anything. (For eg. the HashContent example, that uses this call)
   Moreover it supports funny signatures, like:
   ```
   add_custom_processor("myproc2", .onsc_cb = custom_onschedule_logic);
   ```
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services