You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "freeznet (via GitHub)" <gi...@apache.org> on 2023/02/02 03:54:33 UTC

[GitHub] [pulsar] freeznet commented on a diff in pull request #18951: [improve][fn] support reading config options from file in Function Python Runner

freeznet commented on code in PR #18951:
URL: https://github.com/apache/pulsar/pull/18951#discussion_r1093982208


##########
pulsar-functions/instance/src/main/python/python_instance_main.py:
##########
@@ -49,47 +49,160 @@
 to_run = True
 Log = log.Log
 
+
 def atexit_function(signo, _frame):
   global to_run
   Log.info("Interrupted by %d, shutting down" % signo)
   to_run = False
 
+
+def merge_arguments(args, config_file):
+  """
+  This function is used to merge arguments passed in via the command line
+  and those passed in via the configuration file during initialization.
+
+  :param args: arguments passed in via the command line
+  :param config_file: configuration file name (path)
+
+  During the merge process, the arguments passed in via the command line have higher priority,
+  so only optional arguments need to be merged.
+  """
+  if config_file is None:
+    return
+  config = util.read_config(config_file)
+  if not config:
+    return
+  default_config = config["DEFAULT"]
+  if not default_config:
+    return
+  if not args.client_auth_plugin and default_config.get("client_auth_plugin", None):

Review Comment:
   any chance to simplify this function by [`vars()`](https://docs.python.org/3/library/functions.html#vars)?



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org