sijie commented on a change in pull request #6539:
URL: https://github.com/apache/pulsar/pull/6539#discussion_r398324960



##########
File path: pulsar-function-go/examples/publishFunc/publish_func.go
##########
@@ -0,0 +1,37 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+package main
+
+import (
+       "context"
+
+       "github.com/apache/pulsar/pulsar-function-go/pf"
+)
+
+func contextFunc(ctx context.Context) {
+       if fc, ok := pf.FromContext(ctx); ok {
+               fc.NewOutputMessage("your-publish-topic")

Review comment:
       this doesn't seem to be useful. it just returns a producer and doesn't 
show how to use it. If you are adding an example, you need to add a valid 
example.

##########
File path: pulsar-function-go/pf/context.go
##########
@@ -22,18 +22,24 @@ package pf
 import (
        "context"
        "time"
+
+       "github.com/apache/pulsar-client-go/pulsar"
+       log "github.com/apache/pulsar/pulsar-function-go/logutil"
 )
 
 type FunctionContext struct {
-       instanceConf *instanceConf
-       userConfigs  map[string]interface{}
-       logAppender  *LogAppender
+       instanceConf     *instanceConf
+       userConfigs      map[string]interface{}
+       logAppender      *LogAppender
+       publishProducers map[string]pulsar.Producer

Review comment:
       hmm, I don't think a user should access the message directly.
   
   does go client provide builder-link `newMessage` method?

##########
File path: pulsar-function-go/pf/context.go
##########
@@ -22,18 +22,24 @@ package pf
 import (
        "context"
        "time"
+
+       "github.com/apache/pulsar-client-go/pulsar"
+       log "github.com/apache/pulsar/pulsar-function-go/logutil"
 )
 
 type FunctionContext struct {
-       instanceConf *instanceConf
-       userConfigs  map[string]interface{}
-       logAppender  *LogAppender
+       instanceConf     *instanceConf
+       userConfigs      map[string]interface{}
+       logAppender      *LogAppender
+       publishProducers map[string]pulsar.Producer
+       instance         *goInstance

Review comment:
       I don't understand the usage here. Why do we need to expose `instance` 
publicly?




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


Reply via email to