flowchartsman opened a new issue #8216:
URL: https://github.com/apache/pulsar/issues/8216


   **Describe the bug**
   While the user config is listed as not being implemented for the Pulsar 
Functions SDK for go, the examples seem to indicate that I should be able to 
poll the KVs through the context function, specifically:
   
   ```
   func (c *FunctionContext) GetUserConfValue(key string) interface{} {
       return c.userConfigs[key]
   }
   
   func (c *FunctionContext) GetUserConfMap() map[string]interface{} {
       return c.userConfigs
   }
   ```
   
   However, these do not appear to be getting populated.
   
   **To Reproduce**
   Deploy a pulsar function for go with the following code in main.go:
   ```go
   package main
   
   import (
        "context"
   
        log "github.com/apache/pulsar/pulsar-function-go/logutil"
        "github.com/apache/pulsar/pulsar-function-go/pf"
   )
   
   func contextFunc(ctx context.Context) {
        if fc, ok := pf.FromContext(ctx); ok {
                log.Infof("function ID is:%s, ", fc.GetFuncID())
                log.Infof("function version is:%s\n", fc.GetFuncVersion())
                for k := range fc.GetUserConfMap() {
                        log.Infof("Config %q -> \"%v\"", k, 
fc.GetUserConfValue(k))
                }
        }
   }
   
   func main() {
        pf.Start(contextFunc)
   }
   ```
   
   ```
   $ pulsar-admin functions create --tenant public --namespace default --name 
pfunctestconfig --go (pwd)/pfunctest --inputs persistent://public/default/in 
--output persistent://public/default/out --user-config 
'{"test":"value","testnum":1}'
   ```
   
   
   **Expected behavior**
   Logs look like:
   ```
   2020/10/07 21:27:26.022 log.go:46: [info] function ID 
is:3cbefae6-5a6a-43c5-8427-148625d5f391,
   2020/10/07 21:27:26.022 log.go:46: [info] function version 
is:e215cf0e-2a64-498c-8773-760173de11c3
   2020/10/07 21:27:26.022 log.go:46: [info] Config "test" -> "value"
   2020/10/07 21:27:26.022 log.go:46: [info] Config "testnum" -> "1"
   ```
   
   **Actual behavior**
   ```
   2020/10/07 21:27:26.022 log.go:46: [info] function ID 
is:3cbefae6-5a6a-43c5-8427-148625d5f391,
   2020/10/07 21:27:26.022 log.go:46: [info] function version 
is:e215cf0e-2a64-498c-8773-760173de11c3
   ```


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