jerrypeng commented on a change in pull request #4174: [go function] support
localrun and cluster mode for go function
URL: https://github.com/apache/pulsar/pull/4174#discussion_r279934454
##########
File path:
pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/RuntimeUtils.java
##########
@@ -89,31 +91,180 @@
if (StringUtils.isNotEmpty(extraDependenciesDir)) {
args.add("PYTHONPATH=${PYTHONPATH}:" + extraDependenciesDir);
}
+ } else if (instanceConfig.getFunctionDetails().getRuntime() ==
Function.FunctionDetails.Runtime.GO) {
+ //no-op
}
return args;
}
+ /**
+ *
+ * Different from python and java function, Go function uploads a complete
executable file(including:
+ * instance file + user code file). Its parameter list is provided to the
broker in the form of a yaml file,
+ * the advantage of this approach is that backward compatibility is
guaranteed.
Review comment:
> In process mode, you can do File.deleteOnExit. Because the file is only
used during execution time. You don't really need to save it.
``` File.deleteOnExit ``` deletes the file when the process that created it
exits, but the process that created this file is not the function instance
process, its the worker process. The worker process can run forever.
> But I doubt there is a such thing in arg parsers in any language. Because
as an args parser, you need to distinguish what are options and what are args.
without a predefined list of options, it is hard to know what are options and
what are args, hence it is hard to know what can be ignored.
In python you can do the following:
```
args, unknown = parser.parse_known_args()
```
I get that this would be impossible for positional arguments, but we are not
using any positional arguments. An parameters passed to the instance is in the
form of ```--argument_key <augument_value>```
looking at how arguments are parsed in GO:
https://gobyexample.com/command-line-flags
It seems to me that you explicitly specify which arguments to parse and the
ones you don't just get ignored. Which will be fine for BC as long as we don't
remove any arguments.
> Every language has its own complication. In java, you have to handle
classpath and shading; in Python, you have to handle dependencies, pywheel, and
zip file; In Go, you have to handle the situations introduced due to Go is a
static-linking language. IMO this is not "complication". They are just
different situations introduced by different languages.
Sure we might have to do different things for different languages, but also
it is better if we can minimize these differences so that we don't have to
write a completely different code path to handle each language if possible.
If we can start the GO function without using a file, integration with k8
will require little/no work
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services