wolfstudy 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_r273604165
 
 

 ##########
 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:
   good idea, will fix it.

----------------------------------------------------------------
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

Reply via email to