sijie commented on a change in pull request #4008: [go function]support log
topic for go function
URL: https://github.com/apache/pulsar/pull/4008#discussion_r273542733
##########
File path: pulsar-function-go/pf/instance.go
##########
@@ -259,6 +268,39 @@ func getIdleTimeout(timeoutMilliSecond time.Duration)
time.Duration {
return timeoutMilliSecond
}
+func (gi *goInstance) setupLogHandler() error {
+ if gi.context.instanceConf.funcDetails.GetLogTopic() != "" {
+ gi.context.logAppender = NewLogAppender(
+ gi.client,
//pulsar client
+ gi.context.instanceConf.funcDetails.GetLogTopic(),
//log topic
+
getDefaultSubscriptionName(gi.context.instanceConf.funcDetails.Tenant, //fqn
+ gi.context.instanceConf.funcDetails.Namespace,
+ gi.context.instanceConf.funcDetails.Name),
+ )
+ return gi.context.logAppender.Start()
+ }
+ return nil
+}
+
+func (gi *goInstance) addLogTopicHandler() {
+ if gi.context.logAppender == nil {
+ panic("please init logAppender")
+ }
+
+ for _, logByte := range log.StrEntry {
+ gi.context.logAppender.Append([]byte(logByte))
+ }
+}
+
+func (gi *goInstance) closeLogTopic() {
+ log.Info("closing log topic...")
Review comment:
move this log statement down to before `Stop()`. Because if the logTopic is
not specified it probably doesn't make sense to log the statement here.
----------------------------------------------------------------
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